Subj : Re: [.NET] Volatile Fields [correction] To : comp.programming.threads From : David Hopwood Date : Tue Sep 20 2005 01:59 pm Joe Seigh wrote: > Chris Thomasson wrote: > >> [...] This works in x86: >> >> Processor 1: Y = 1; L = 1; >> Processor 2: if (L == 1) { Z = 1; L = 2; } >> Processor 3: if (L == 2) { assert( Z == 1 && Y == 1 ); } >> >> http://groups.google.com/group/comp.programming.threads/msg/68ba70e66d6b6ee9?hl=en >> >> L is a lightweight memory barrier. > > You don't need the load on the "memory barrier". > > W = X = Y = Z = 0; > > Processor 1: W = 1; L = 1; X = 1 > Processor 2: if (X == 1) { Y = 1; L = 1; Z = 1; } > Processor 3: if (Z == 1) { assert (W == 1 && Y == 1); } > > W and Y are stored by two different processors and are seen in order. What are the stores to L for? W = X = Y = Z = 0; Processor 1: W = 1; X = 1; Processor 2: if (X == 1) { Y = 1; Z = 1; } Processor 3: if (Z == 1) { assert (W == 1 && Y == 1); } cannot fail the assert (for processor consistency / x86 WB / .NET with volatiles). -- David Hopwood .