Subj : Re: [.NET] Volatile Fields To : comp.programming.threads From : David Hopwood Date : Sat Sep 17 2005 02:59 pm Cool Guy wrote: > Joe Seigh wrote: > >>Cache has no effect on read/write ordering. It's the memory model that does. >>You could have a system without cache and it would still have the same issues >>with read/write ordering. So trying to imagine what is happening with a >>hardware entity, which by definition you can't see, only serves to confuse >>yourself. > > My confusion arises from the fact that only *one* of those fields is > volatile in the example linked from the OP, and not *both* of them, which > leads me to believe that the one field that isn't volatile could be > read/written from/to the cache instead of from/to main memory and thus the > code isn't thread-safe. The release and acquire barriers referred to on the example page are global barriers that apply to all locations, regardless of whether they are cached or accessed through volatile variables. (You could argue that this is potentially inefficient, but current SMP systems are designed to support it, at some cost in hardware complexity and scalability.) -- David Hopwood .