Subj : Re: double-checked locking in C To : comp.programming.threads From : David Hopwood Date : Fri Jul 08 2005 12:49 am Laurent Deniau wrote: > David Hopwood wrote: >> Laurent Deniau wrote: >>> David Hopwood wrote: >>> >>>> You're mistaken; processors can reorder memory accesses across jumps. >>> >>> I was abusively talking of a jump while in fact the goal was to have >>> a call. I don't know if processor can do tentative evaluation of a >>> call, but the value it has to assigned is returned by value from the >>> call. >> >> You don't know how the compiler will implement the function call. > > When you are talking about compiler, do you mean compiler front-end > which call the linker or just the C compiler? I meant "compiler" as a shorthand for "language implementation". The structure of the language implementation is basically irrelevant; it doesn't matter what the parts of the implementation that can cause memory accesses to be reordered are called. > Because the C compiler > will have absolutely no knowledge of the function called except its > prototype. So what kind of optimization and speculation could be > possible with that foreign function before the linking phase (note that > it could happened at runtime)? This focus on trying to prevent the language implementation from being able to perform certain optimizations is utterly misguided, because: a) the implementation may be too clever, and b) the processor (if you don't consider that to be a part of the language implementation) can also do similar optimizations. -- David Hopwood .