Subj : Re: Memory Barriers, Compiler Optimizations, etc. To : comp.programming.threads From : Alexander Terekhov Date : Thu Feb 03 2005 04:33 pm Markus Schaaf wrote: [...] > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf_readwritebarrier.asp.) > > It seems worth noting, that acquire and release barriers are just a variety > of memory visibility models. If you are concerned with broader aspects of > memory visibility, say, from perspective of a general purpose programming > language, it might be useful to widen the focus. Right. Idiotic "global memory" optimization blocker aside for a moment, MS folks actually meant: int G; int i; atomic ReleaseF(0), WaitF(0); void f(void *p) { G = 1; WaitF.store(1, msync::ssb); while (ReleaseF.load(msync::hsb) == 0); G = 2; } int main() { _beginthread(f, 0, NULL); // New thread while (WaitF.load(msync::hlb) == 0) Sleep(1); if (G == 1) puts("G is equal to 1, as expected."); else puts("G is NOT equal to 1!"); ReleaseF.store(1, msync::slb); } regards, alexander. .