5ec Subj : Re: double-checked locking in C To : comp.programming.threads From : Laurent Deniau Date : Thu Jul 07 2005 09:40 pm David Hopwood wrote: > Laurent Deniau wrote: > >> David Hopwood wrote: >> >>> Laurent Deniau wrote: >>> >>>> The compiler is not allowed to assign initialized *before* >>>> extern_init_code() returns. The processor will not be able to do the >>>> same since this is a true jump with a return value. >>> >>> >>> 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 frond-end which call the linker or just the C compiler? 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)? > if it uses processor instructions designed for the implementation of > calls, however, it is still possible for reordering and speculative > execution to occur across these instructions. Do you performing something else than a call which would not be ABI conformance? ld. . 0