[cpp-threads] Yet another visibility question
Peter Dimov
pdimov at mmltd.net
Sat Nov 18 03:03:49 GMT 2006
Let me re-ask the same question again using slightly different wording. I'm
really not sure of the correct answer. "Correct" as in both "follows from
the memory model", and "what we want".
// x y z initially zero
// thread 1
x = 1;
fetchadd_release( &z, +1 );
// thread 2
y = 1;
fetchadd_release( &z, +1 );
// thread 3
if( load_acquire( &z ) == 2 )
{
assert( x == 1 && y == 1 );
}
Will the assert pass?
In other words, does the load-acquire from z in thread 3 introduce sync-with
edges to all previous store-releases to z, or just to the last one?
More information about the cpp-threads
mailing list