Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : Uenal Mutlu Date : Sat May 21 2005 03:53 am "David Schwartz" wrote > > "Uenal Mutlu" wrote in message > > >> See also this DOC of Micro$oft: > >> http://www.microsoft.com/whdc/driver/kernel/locks.mspx > >> (http://download.microsoft.com/download/e/b/a/eba1050f-a31d-436b-9281-92cdfeae4b45/Locks.doc) > > > > Citation from the above DOC: > > > > "InterlockedXxx Routines > > The InterlockedXxx routines perform common arithmetic and logical > > operations atomically, > > ensuring correct results on SMP systems. Whenever possible, drivers should > > use these routines. > > Most of them are native processor instructions and therefore do not > > require a lock. > > The InterlockedXxx routines can be used with pageable data. They are > > usually > > implemented inline by the compiler and can be called at any IRQL." > > Then you've reinvented a less-efficient version of the spinlock. > Congratulations. > (Hint: What is the InterlockedXxx routine to check the value of a something without unsharing it?) Wrong. All the effort is because it IS shared! If yo don't see it then I'm sorry for you: thread1: sets the shared condition variable. thread2: sets the shared condition variable. thread3: waits for the shared condition variable to have a specific value. Do you now understand that it is shared by multiple threads? The variable could also be set to any other value but just the 0 and 1. .