[cpp-threads] Yet another visibility question

Peter Dimov pdimov at mmltd.net
Wed Nov 22 10:36:21 GMT 2006


Another question:

// x y initially zero

// threads 1 to N:

assert( x == 0 );

if( fetchadd_release( &y, 1 ) == N - 1 )
{
    x = 1;
}

Are the asserts guaranteed to pass? Informally, the causality constraint 
prevents the compiler or the hardware from speculatively executing the store 
before the fetchadd, even though there's no acquire label. But what does the 
MM say? 




More information about the cpp-threads mailing list