Boost logo

Boost :

Subject: Re: [boost] [lockfree] review
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-08-02 12:47:55


on Mon Aug 01 2011, Gordon Woodhull <gordon-AT-woodhull.com> wrote:

> On Aug 1, 2011, at 10:49 AM, Dave Abrahams wrote:
>> on Mon Aug 01 2011, Gordon Woodhull <gordon-AT-woodhull.com> wrote:
>>> All of the classic lock-free algorithms, including those that are the
>>> basis for the synchronization primitives we should usually use, have
>>> data races.
>>
>> IIUC, accesses to atomics are not in and of themselves data races. But
>> it doesn't surprise me a bit to learn (again) that lock-free algorithms
>> are hard to think about.
>
> This is the part of the theory that seems like a cop-out to me. You
> can declare certain variables to be atomic/for synchronization and
> then *by definition* it's not a data race? Excuse me? No. It's
> still a race, but it's one that's condoned because you've told the
> implementation that you want it to be there.

It's not really different than locking. If you want to write to shared
data, you need some way of making it not-a-race. It's just that when
the data structure is small enough (like an int) you can make it atomic
instead of putting a lock around it.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk