[cpp-threads] Yet another visibility question
Peter Dimov
pdimov at mmltd.net
Wed Nov 29 23:46:56 GMT 2006
Boehm, Hans wrote:
> Partially correcting myself:
>
> I think the analysis below applies if x is an atomic, even if it is
> accessed with unordered operations. If x is an ordinary variable,
> there is a race between the assert and the assignment to x. And I
> think that's what we want here.
x is an ordinary variable in the example.
It's not clear what we want to happen in this case. What I want is for
reference counting to be as efficient as possible (within the confines of
the model, of course.)
If the causality requirements of the model effectively imply that in the
real world the store to x can never race with the assert, then I wouldn't
want to be forced to put a redundant ordered fetchadd(&y, 0) between the two
just to satisfy the spec.
>>>> // x y initially zero
>>>>
>>>> // threads 1 to N:
>>>>
>>>> assert( x == 0 );
>>>>
>>>> if( fetchadd_release( &y, 1 ) == N - 1 ) {
>>>> x = 1;
>>>> }
More information about the cpp-threads
mailing list