Re:1024cores
by tedunangst on Friday December 31, 2010 @04:19PM
(#2056496)
That only works with coherent in order memory operations. Once you add the appropriate memory barriers, it looks a lot more "atomic".
I chose that example because its easy to understand, obviously in modern processors with out of order execution and whatnot, you would need something a lot more elaborate.
Once you add the appropriate memory barriers, it looks a lot more "atomic"
Well, they force in order memory access. That doesn't look terribly "atomic" to me, but I understand your point.
An example of mutual exclusion, without any atomic operations, taken from the book "The art of multiprocessor programming"[1] is (paraphrased) as follows:
Two threads, A and B, want to access some memory. Each thread has a flag.
When thread A wants to access the shared memory:
When thread B wants to access the shared memory: Obviously this isn't a general purpose solution, but rather an easy to understand example demonstrating that atomic operations are not required.[1] http://www.amazon.com/Art-Multiprocessor-Programming-Maurice...