607 Subj : Re: [.NET] Volatile Fields [correction] To : comp.programming.threads From : Joe Seigh Date : Tue Sep 20 2005 02:03 am Joe Seigh 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. > > processor 1: > store fence; // "fence" is common global location > store x; // store some value > > processor 2: > load x; // load some value > load fence; // > > > If processor 2 sees the store into x by processor 1 it will see the store > into fence. Since "fence" is used as the common memory barrier, you get > transitivity of memory visibility. No CMPXCHG required. Actually, you may not need that "load fence", just the "store fence", though you may need an LFENCE depending on what you think LFENCE actually does. The memory visibility from interlocked instructions is slightly different so you need to be careful mixing them with the above. By themselves (i.e. locks) you don't need a global memory barrier. The more general pattern is you need to store into the same "release store location" used by another processor to make it's stores transferable (transitive) by your store. You can have multiple release store locations but you need to chain them together correctly to get proper transitivity. Something like that anyway. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. . 0