My question: Do green threads naturally do atomic reads/writes to variables such that mutexes are pragmatically not needed in most situations in Chicken?
I have seen corrupted values which I assumed were due to reading/writing to variables from multiple threads without mutex protection. However when I tried to simulate this (code pasted below) I haven't been able to create any collisions.
Note that where file handles and ports are being opened/closed with subprocesses etc then mutexes are absolutely needed. I ran into this with trying to use nanomsg in threads where subprocesses were being launched. Without mutexes it crashed very quickly. It is possible that the corrupted values I've seen in the past were actually due to open/closing of file handles, ports and or processes along with cross threaded variable accesses.
But back to the question, are mutexes really needed when passing variables back and forth between srfi-18 threads in Chicken? Perhaps my code below is too simplistic to trigger a collision? Mutexes can have a pretty severe impact on performance and it would be nice to know when they are really needed. The srfi-18 documentation is crystal clear that they should be used always but maybe in the case of chicken it is ok to bend the rules?