[cpp-threads] modes

Doug Lea dl at cs.oswego.edu
Sun May 8 01:02:45 BST 2005


> Well, for example, try 
> 
> http://www.google.com/search?q=read_barrier_depends
> 
> What they actually mean is msync::ddhlb label on dereference. 
> 
> McKenney's "rcu_dereference" comes pretty close, so to speak.
> 
> Sorta existing practice, oder? ;-)

But compiler-based barrier optimization for these kinds
of cases seems straightforward. When usages are along the lines of:

atomic<Stuff*> asp;
...
Stuff* p = asp.read_acquire();
if (p != null)
    x = p->y;
    ...
...

If a compiler knows that its target platform doesn't
need read barriers when all future actions are dependent
on a branch and/or pointer deref, it can remove the barrier by itself
without you having to use a special mode to tell it. The "all"
part looks like a big restriction but I think rarely is.

-Doug









More information about the cpp-threads mailing list