[cpp-threads] Yet another visibility question

Lawrence Crowl Lawrence at Crowl.org
Mon Nov 20 19:32:44 GMT 2006


On 11/17/06, Peter Dimov <pdimov at mmltd.net> wrote:
> 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?

I'd need to look more carefully to be sure, but I think all edges.

In any case, I think introducing only the last edge would produce
a programming model that is effectively unusable.

-- 
Lawrence Crowl



More information about the cpp-threads mailing list