Subj : Re: double-checked locking in C To : comp.programming.threads From : Laurent Deniau Date : Wed Jul 06 2005 04:53 pm Joe Seigh wrote: > Laurent Deniau wrote: > >> Joe Seigh wrote: >> >>> >>> Most people don't realize that it's not just reads that can be out of >>> order but writes as well. So you need release semantics on the store >>> of the init flag as well as acquire semantics on the load of that flag. >> >> >> >> This is done by the mutext lock and unlock. They unsure >> synchronization of the memory content with other threads (otherwise >> mutex would be completely useless). I do not have to deal with such >> problem (and it is not possible at the level of C). > > > The mutex doesn't affect the order of stores as seen by other threads > *not* using the mutex. Right. And? I still not see any problem. >>> There was nothing in your example showing that the initialization stores >>> had to appear in memory before the store to the init flag did. >> >> >> >> This is the problem of unlock, not mine. Between the lock/unlock I >> *only* must ensure that if other threads see a value in the first test >> (by a premature memory commit), it is a valid value, which by the way >> never change after being set. The rest is done by lock/unlock. >> >> Remember the context: C language, singleton pattern (or unique >> initialization) and DCL. Nothing more. >> >> If you still see a problem in my code, please show me a sequence of >> actions (sequence points) done by two (or more) threads which breaks >> the semantic of the singleton pattern. >> > No, sorry. The burden of proof is on you. And the reason I posted the > URL is so we don't have to disprove every bogus DCL implementation there > is over and over again. How I can I prove that there is no bogus? If the DCL code shown is so easy to break, show me a sequence of actions (points). I can detail all steps for different cases, but it will be much longer than showing a single bogus case, if any. > Another URL you can check out > http://www.nwcpp.org/Downloads/2004/DCLP_notes.pdf Thanks, but at first quick reading, I still do not see problems. ld. .