4d2 Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : David Schwartz Date : Sat May 21 2005 09:47 am "Uenal Mutlu" <520001085531-0001@t-online.de> wrote in message news:d6mvo3$md$03$1@news.t-online.com... >> Show me in code how you wait for a condition variable without >> unsharing >> it. By "unsharing it", I mean making it no longer shared in the CPU's >> cache. > I've shown that already, see prev. posting. > There is nothing special to do by the user about it. It is sufficient > just to use the InterLockedXXX funcs to set and get the atomic variable. > Requirements for a variable to be used by InterlockedXXX (on x86, MSVC > compiler), > is that it must be volatile and right aligned, and of size of the natural > word size > of the CPU: here 32 bit integer on 32 bit CPUs: > > // a right aligned 32 bit integer on x86 (MSVC code): > #pragma pack(push, 4) > volatile long lVar; > #pragma pack(pop) > > Of course such things are best packed (hidden) inside a handy class in > C++. You still haven't answered my question. Show me the code that allows you to test the value of a shared atomic type without unsharing it. DS . 0