[cpp-threads] Alternatives to SC (prohibiting data races, etc.)

Boehm, Hans hans.boehm at hp.com
Thu Feb 1 22:22:07 GMT 2007


> From: lawrence.crowl at gmail.com 
[Load_raw/relaxed:]
> > And this will do a load without memory barriers or atomics,
> 
> That is an implementation question that can only be answered 
> with respect to a given platform.
> 
> The paper has a (really, really) minimal conforming 
> implementation, and its atomic_load_relaxed() effectively uses a lock.
> 
> Some people believe that on x86, a simple load is sufficient.
I would add that if this is not sufficient for a suitably designed ABI,
then we have a problem.  (As I recall, not all X86 ABIs properly align
pointers, but I think pretty much all relevant ones do.)

> 
> > but with no danger of subsequent refetches?
> 
> What do you mean by "refetch" here?
The memory model promises that your code is executed as if it returned
the value of a particular store.  Implicitly, it cannot appear to fetch
one thing and then later change its mind.  Thus "refetches" are not
allowed for any atomics.

Hans

> 
> > And, if applied to a lock_free() datum, the load is atomic 
> in that it 
> > sees the value from a particular prior store (or the initial value)?
> 
> That should be true regardless of the result of lock_free().
> (Remember to be careful about what "prior" means.)
> 
> --
> Lawrence Crowl
> 



More information about the cpp-threads mailing list