Subj : Re: double-checked locking in C To : comp.programming.threads From : Peter Dimov Date : Sat Jul 09 2005 02:51 pm David Schwartz wrote: > "Peter Dimov" wrote in message > news:dan5la$5qg$1@domitilla.aioe.org... > >> "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. >> If we assume an implementation where >> "volatile access" maps to a load instruction and "volatile write" >> maps to a store instruction, then we can talk about a sequence of load and store instructions. If we don't, we can't. For the standard to have a meaning in a particular context, the implementation must specify what constitutes observable behavior in this context. "Observable behavior" is the link between the formal specification and the real world. The typical case is described above. .