Erik Trulsson wrote:
It is also worth noting that just declaring a variable 'volatile' does not help all that much in making it safer to use in a threded environment if you have multiple CPUs. (There is nothing that says that a multi-CPU system has to have any kind of automatic cache-coherence.)
The first sentence here could be misleading, there are LOTS of systems where there is automatic cache-coherence, and of course the use of 'volatile' on such systems does indeed help. If you are working on a systemn without cache-coherence, you indeed have big problems, but that's rarely the case, most multi-processor computers in common use do guarantee cache coherence.