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

Lawrence Crowl Lawrence at Crowl.org
Thu Feb 1 02:58:03 GMT 2007


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

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

-- 
Lawrence Crowl



More information about the cpp-threads mailing list