[cpp-threads] Yet another visibility question

Peter Dimov pdimov at mmltd.net
Tue Dec 19 11:45:03 GMT 2006


Boehm, Hans wrote:

> A very simple (perhaps too simple) counter-example is
>
> r1 = x.load_raw();
> if (r1) {
>   y = 1;  // y not atomic
> } else {
>   y = 1;
> }
>
> I think we really have to declare the stores here to be dependent on
> the load, since each one is.

I'm not sure. We define a store to be dependent if different values of r1 
can cause it to write different values (where not writing at all is 
considered different from writing any value). In this example, changing the 
value of r1 cannot cause different values to be written to y. The static 
code structure (the presence of an if statement) does not and cannot 
determine dependence.

if( f( r1 ) >= 0 )
{
    y = 1;
}

Is this dependent? We can't say without knowing whether f() can return a 
negative value. 




More information about the cpp-threads mailing list