Subj : Re: [.NET] Volatile Fields [correction] To : comp.programming.threads From : David Hopwood Date : Tue Sep 20 2005 03:31 pm Joe Seigh wrote: > David Hopwood wrote: >> Joe Seigh wrote: >> >>> 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). > > W and Y are stores by two different processors. Under processor > consistency you aren't guaranteed to see them in order. . : # Condition 1: Conditions for Processor Consistency # # (A) before a load is allowed to perform with respect to any other # processor, all previous load accesses must be performed, and # (B) before a store is allowed to perform with respect to any other # processor, all previous accesses (loads and stores) must be performed. Before X = 1 performs wrt P2, W = 1 must have performed wrt P3. Before Z = 1 performs wrt P3, Y = 1 must have performed wrt P3. > And I'm talking about processor consistency w/o .NET volatiles. As far as I can tell, the rules for .NET volatiles are just processor consistency; nothing more, nothing less. Makes sense given Microsoft's emphasis on x86[-64]. -- David Hopwood .