Subj : Re: double-checked locking in C To : comp.programming.threads From : David Hopwood Date : Sat Jul 09 2005 11:50 pm Peter Dimov wrote: > David Schwartz wrote: >>"Peter Dimov" wrote: >> >>>"As if" means that the compiler can achieve the required observable >>>behavior in whatever way it likes. If we assume an implementation where >>>"volatile access" maps to a load instruction and "volatile write" >>>maps to a store instruction, "as if" means that the compiler can >>>elide or reorder all other memory accesses and optimize out or overlap >>>all nonvolatile objects as long as the sequence of loads/stores >>>corresponding to volatile accesses/writes remains in place. >> >> What is "the sequence of loads/stores"? In the CPU instruction >>stream? On the memory bus? To the cache? You are doing the same thing >>you said you could not do. How can the C standard specify where the >>sequence of loads/stores is to be observed? > > You haven't read my post. > > The mapping of "observable behavior" (as used by the standard) to real-world > events is implementation defined. "Implementation-defined", in the context of C, implies "must be documented". Have you ever seen adequate documentation of precisely what volatile means for a specific platform? I haven't; basically you just have to guess and hope that the implementation doesn't do optimizations that break your code. -- David Hopwood .