65f Subj : Re: [.NET] Volatile Fields [correction] To : comp.programming.threads From : David Hopwood Date : Tue Sep 20 2005 02:57 am Joe Seigh wrote: > Sean Kelly wrote: >> Cool Guy wrote: [...] >>> So it's impossible to make such code thread-safe, then? >> >> Simply by following the (sparsely) documented x86 memory model? Yes. >> Though Alexander suggested a method that should work on existing CPUs: >> replace load instructions with CMPXCHG. This relies on a comment in >> the docs for CMPXCHG that says a write is always performed when this >> instruction is executed, even if the value is not changed as a result >> of the operation. Hardware folks may argue that this is an >> implementation detail however (as Andy Glew did), so future x86 CPUs >> may not guarantee the same behavior. > > AFAICT, Alexander seems to think the x86 memory model is just PC and > *all* of the other stuff in the x86 docs doesn't count. *Most* of the other stuff in the x86 docs is about non-WB memory types, or about what is visible on the system bus, as opposed to what is visible to processors. > Seems a bit arbitrary and selective to me. Andy Glew wrote: # [...] the above can be briefly stated: WB memory is processor consistent, # type II. > If you want to do global memory barriers just using PC and nothing else, > you can. Just use a common memory location to "sync" everything with. If you don't care about lousy performance due to cache line pinging. -- David Hopwood . 0