Hacker News new | ask | show | jobs
by torginus 14 days ago
They very well can be. The CPU mutexes use some form of cache-coherency mechanism based on the MESI protocol - essentially each CPU keeps track of which other cores have a certain piece of memory in their cache, and if any of them modified it.

You can do better than that, for example, I remember reading an article about some game engine, which had a static scheduling of tasks on each frame, so, for example there was no overlap in time between thread A and thread B referencing the same piece of memory. The whole scheme worked the exact same every frame, it was truly free, and there was a zero percent chance of memory inconsistencies.