Subj : Re: [.NET] Volatile Fields [correction] To : comp.programming.threads From : Joe Seigh Date : Tue Sep 20 2005 08:30 am Chris Thomasson wrote: >>If you want to do global memory barriers just using PC and nothing else, >>you can. Just use a common memory location to "sync" everything with. >>E.g. > > [...] > > Yup. 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. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .