Very limited shared promotion

Timon Gehr timon.gehr at gmx.ch
Mon Jun 24 13:12:44 UTC 2019


On 24.06.19 04:44, Walter Bright wrote:
> On 6/22/2019 4:24 PM, Manu wrote:
>> If you engage in @system code to distribute across threads, it's a no 
>> brainer to expect that code to handle cache coherency measures. It 
>> would be broken if it didn't.
> 
> It is not a no-brainer. Nowhere is it specified, and all the examples 
> and tutorials I've seen say DO NOT follow an atomic write with a 
> non-atomic read of the same variable in another thread. Not only that, 
> it's usually a CENTRAL THEME of these expositions.
> ...

Are you saying code like the following would have UB?

__gshared int x=0, y=0;
void thread1(){
     x.write(1,release);
     y.write(1,release);
}

void thread2(){
     if(y.read(acquire)==1){
         assert(x==1); // plain read
     }
}


More information about the Digitalmars-d mailing list