[cpp-threads] Alternatives to SC (prohibiting data races, etc.)
Paul E. McKenney
paulmck at linux.vnet.ibm.com
Thu Feb 1 05:50:05 GMT 2007
On Wed, Jan 31, 2007 at 06:58:03PM -0800, Lawrence Crowl wrote:
> On 1/31/07, Paul E. McKenney <paulmck at linux.vnet.ibm.com> wrote:
> >OK -- but I didn't see load_raw() in N2145. This is something you
> >are proposing adding -- or did I get the wrong document?
>
> Look under core functions, for the definition:
>
> inline ${TYPENAME} atomic_load_${READ}( atomic_${TYPEKEY} volatile * __a__ )
>
> After choosing appropriate values for the variables, you have
>
> int atomic_load_relaxed( atomic_int volatile * __a__ )
>
> The use would be
>
> extern atomic_int av;
> .... int v = atomic_load_relaxed( &av ); ....
OK, so the real name is atomic_load_relaxed() as opposed to load_raw()?
And this will do a load without memory barriers or atomics, but with no
danger of subsequent refetches? 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)?
> >So atomic<char>::lock_free() would normally (always?) return true, while
> >atomic<struct foo>::lock_free() would normally return false, right?
>
> Right, presuming struct foo is big enough. If it is small, it could
> be lock free.
Good point!
Thanx, Paul
More information about the cpp-threads
mailing list