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

Paul E. McKenney paulmck at linux.vnet.ibm.com
Thu Feb 1 20:41:02 GMT 2007


On Thu, Feb 01, 2007 at 10:56:36AM -0800, Lawrence Crowl wrote:
> On 1/31/07, Paul E. McKenney <paulmck at linux.vnet.ibm.com> wrote:
> >OK, so the real name is atomic_load_relaxed() as opposed to load_raw()?
> 
> In the current paper, yes.  I hesitate to make a claim about the standard
> itself as there are several months and several votes left.  :-)

Wise man!!!  ;-)

> >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.

OK.

> >but with no danger of subsequent refetches?
> 
> What do you mean by "refetch" here?

If the compiler has register-allocation problems, and needs to spill
the value that was loaded via atomic_load_relaxed(), will it be
enlightened enough to spill to a temporary rather than trying to
reload from the original variable, which might well have changed
in the meantime?

> >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().

Because the compiler will use a lock if necessary, correct?

> (Remember to be careful about what "prior" means.)

;-)

							Thanx, Paul



More information about the cpp-threads mailing list