|
Boost : |
Subject: Re: [boost] [lockfree] review
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2011-08-25 00:25:06
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.
> The Standard's focus on sequential consistency by default was carefully thought out.
I find that most lockfree development uses acquire/release, not SC, so
if the focus was to standardize existing patterns (at least in
lockfree), then in that sense it seems odd. But I do believe it was
carefully thought out, and by people who know better than I. I have a
slight worry that SC was chosen so that it was easier to understand in
general, instead of for those who will probably use it most, but
again, I wasn't there, and really, I think that the memory ordering of
an atomic operation is important enough that I might argue that it
should always be specified, so I don't at all mind that I need to be
explicit to use acqure/release. (sorry for the run on sentence)
Tony
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk