Date: 2001-11-16 09:31:29
> From: Kevin Cline [mailto:kcline_at_[hidden]]
> The double-checked locking idiom is not safe on multi-processor systems.
> There was considerable discussion of this in comp.lang.c++.moderated
> a couple of years ago, but eventually everyone saw that it was unsafe.
> On p. 148 of Alexandrescu's "Modern C++ Design" he nicely summarizes
> the discussion:
> Very experienced multithreaded programmers know that even the
> Double-Checked Locking system ... is not always correct
> in practice.
> In certain symmetric multiprocessor environments ... the
> writes are
> committed to the main memory in bursts, rather than one by one.
> ... Due to this rearranging of writes, the memory as seen by one
> processor might look as if the operations are not performed
> in the correct order by another processor... the Double-Checked
> Locking pattern is known to be defective for such systems.
OK -- I had to go look up these discussions (I don't have group access :( ).
First, some scope: this applies only to relaxed-memory model symmetric
Second: I don't see how these systems could possibly claim to be conforming
anyway -- I have the usual questions about the guarantee of observable
behaviour, side effects, and sequence points -- which I'm sure you've heard
before. My question: why can't these guarantees be used to prevent problems
with double-checked locking? I did not find any threads where these were
BTW, please respond privately; this really isn't a Boost discussion.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk