Subj : Re: Memory visibility and MS Interlocked instructions To : comp.programming.threads From : Peter Dimov Date : Sat Sep 03 2005 01:59 pm Alexander Terekhov wrote: > David Hopwood wrote: > > it, but most lock-free stuff doesn't need it, because it doesn't rely on > > total store (or load) ordering. It's been my impression that lock-free usually relies on a transitive happens-before... but I may be wrong. > Yep, most lock-free stuff doesn't rely on "atomic visibility" (remote > write atomicity). 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; } 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? If this is not true, the happens-before model breaks, and it's impossible to write programs against it. (I don't think that a non-broken happens-before requires write atomicity - it's still weaker than that - but I may be wrong about that as well.) I'm obviously missing something. .