|
Boost : |
Subject: Re: [boost] [lockfree] review
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2011-08-25 07:38:15
Gottlob Frege wrote:
>
> On Thu, Aug 25, 2011 at 12:13 AM, Stephan T. Lavavej
> <stl_at_[hidden]> wrote:
> > [Gottlob Frege]
> >> 1. I wish that C++11 atomics defaulted to acquire-on-read and
> >> release-on-write, and that's how I will almost always use them. It is
> >> also what java and C# use, I believe (on volatiles).
> >
> > That doesn't solve the "independent reads, independent writes"
> > problem, which is why the non-Standard semantics that VC8 gave
> > volatile aren't really useful. (volatile: a multithreaded
> > programmer's worst enemy.)
> >
>
> What's the "independent reads, independent writes" problem? I've
> probably heard, seen, or mistakenly had a bug due to it once, but
> don't know it by name.
IRIW is an example that highlights remote write atomicity:
T1: X = 1;
T2: Y = 1;
T3: A = X; B = Y;
T4: C = Y; D = X;
A == 1 && B == 0 && C == 1 && D == 0 is possible without remote write
atomicity.
Another example is
T1: X = 1;
T2: if (X) Y = 1;
T3: A = Y; B = X;
A == 1 && B == 0 is possible without remote write atomicity.
SC is basically "no local reordering" plus remote write atomicity.
In 'modes' model, remote write atomicity is a separate mode apart from
reordering.
regards,
alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk