Subj : Re: double-checked locking in C To : comp.programming.threads From : David Schwartz Date : Fri Jul 08 2005 06:02 am "Laurent Deniau" wrote in message news:dalle2$nlu$1@sunnews.cern.ch... > The as-if rule is an implementation-defined problem. The as-if-safe rule > becomes an as-if-unsafe rule because of some changes in the context of > execution which is not considered by the implementation (e.g. switching > off the computer). Unless specified, this is leading to an undefined > behavior. Imagine that the implementation of volatile includes memory > barrier or some cache synchronisation mechanism (nothing in the C says to > not do so), it would still be conform with and without thread. But at the > price of hidden penalties that C programmers do not want to hear about. Since no standards compliant C code can tell the difference, the C standard cannot require the barriers. Some other standard (for example, a threading standard) might specify that volatile provides ordering guarantees across threads, in which case failure to provide barriers might lead to violating that standard on that platform. DS .