Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : Peter Dimov Date : Thu May 26 2005 06:00 pm David Schwartz wrote: > "Peter Dimov" wrote in message > news:d71qq6$gcf$1@domitilla.aioe.org... > >> David Schwartz wrote: > >>> Suppose you are thread "A1". The lock is held by "A2" and >>> transfers to "B1" while you are checking the owner field. What stops >>> you from seeing half of each and getting "A1", and thinking you own >>> the lock? > >> We've been assuming atomic reads and writes, just no msync. > > You're assuming more than just atomic reads and writes. Even if the > reads and writes are atomic with respect to the CPU instruction > stream, they could still span a cache line and not appear atomic on > another CPU. You are actually assuming quite a few platform-specific > things. I'm relatively new to this group, so if it is customary here to have "atomic reads and writes" mean "atomic reads and writes with respect to the CPU instruction stream", apologies. It's hard to see how this definition of "atomic" could be useful or even sensible, but to each his own. .