|
Boost : |
Subject: Re: [boost] [lockfree] review
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2011-08-29 13:08:49
Dave Abrahams wrote:
>
> on Sat Aug 27 2011, Gottlob Frege <gottlobfrege-AT-gmail.com> wrote:
>
> > There is no "synchronizes with" (standard's wording) because
> > synch-with requires thread 2 to *read* the value written into the
> > atomic by thread 1. We have no reads here - no if statement - so
> > reordering doesn't matter.
> > I don't think the standard disallows the reordering of i and j, even
> > if they are atomics.
>
> IIUC from the point of view of programs without undefined behavior, the
> standard disallows reordering in both cases.
The standard prescribes UB in the case of lock-free non-atomic observer
loads (the program is well-defined in the case of relaxed lock-free
atomic stores and loads to observe the reordering of two stores).
In reality, the generated code is the same (irrespective of whether the
code uses relaxed atomic stores/loads versus ordinary stores/loads).
The standard allows reordering in both cases. The only difference is UB
imposed by fiat in one case and no UB in another case.
regards,
alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk