Subj : Re: Memory visibility and MS Interlocked instructions To : comp.programming.threads From : Peter Dimov Date : Sat Sep 03 2005 02:28 pm Alexander Terekhov wrote: > Peter Dimov wrote: > [...] > > I find that very odd. Not the absence of atomic visibility per se, > > but... > > > > P1: X = 1; #storestore; Y = 1; > > P2: if( Y == 1) { #loadstore; Z = 1; } > > That's dependent store, no barrier needed. Added for completeness' sake. > > P3: if( Z == 1) { #loadload; assert( X == 1 ); } > > > > If Z == 1 happens before X == 1, Z = 1 happens-before Z == 1, Y == 1 > > happens-before Z = 1, Y = 1 happens-before Y == 1 and X = 1 > > happens-before Y = 1, then X = 1 happens-before X == 1, right? > > Right. Under PC, > > P1: X = 1; Y = 1; > P2: if( Y == 1) { Z = 1; } > P3: if( Z == 1) { assert( X == 1 ); } > > Z == 1 && X != 1 is false. Great. But P1: Y = 1; P2: if( Y == 1 ) { Z = 1; } P3: if( Z == 1 ) { assert( Y == 1 ); } may assert. This still breaks happens-before; there is a similar Y = 1 << Y == 1 << Z = 1 << Z == 1 << (other) Y == 1 chain. .