Subj : Re: double-checked locking in C To : comp.programming.threads From : Joe Seigh Date : Fri Jul 08 2005 09:06 am Alexander Terekhov wrote: > Laurent Deniau wrote: > [...] > >>Right. Comming back to the example, returning from a function is a >>sequence point. > > > "The C standard says that it must look that way from the point of > view of the abstract machine defined by the standard. But the as-if > rule says that things can be arbitrarily reordered as long as nobody > can tell. Since the standard says nothing about threading, it does > not concern itself with statement reorderings that are as-if-safe > under one thread of control but as-if-unsafe under multiple threads > of control." > The problems is threading is talked about as if it has well defined behavior outside of C. It doesn't. "threading" and Posix pthreads aren't the same thing. And even Posix pthreads has no formal definition. You can't say what it actually does. I don't know what Posix compliance entails but one thing it doesn't is proving the C compiler in question correctly implements a certain behavior since that certain behavior has no definition. So when you talk about things like out of order memory access, that's one form of threading as we understand it. Since Posix , Ansi C, and hardware designers don't talk to one another, it's possible for a new "thread" model / memory model / hardware architecture that breaks not only heretofore correct DCL implementations but Posix pthreads as well. You'd have to port the DCL and Posix pthreads to the new architecture, assuming it's possible. So given that both can break and somebody has to do the porting, I'd say both DCL and Posix are equally portable except there's probably more headcount available to do the porting for Posix pthreads. AKA future proofing and no, you can't future proof anything. That's why C doesn't work for things it never anticipated and Posix pthreads won't work for things it never anticipated. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .