508 Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : David Schwartz Date : Wed May 25 2005 07:22 am "Peter Dimov" wrote in message news:d71qq6$gcf$1@domitilla.aioe.org... > David Schwartz wrote: >> "doug" wrote in message >> news:ZyPje.1900$iq5.1180@fe1.news.blueyonder.co.uk... >>> I know where you're coming from - that's where I came from too. But >>> some folk (Peter, Giancarlo) explained that *yes*, you might read >>> the wrong value, but it doesn't matter. You're guaranteed to get >>> the answer to the question "do I own this lock" correct. >> >> Guaranteed by what? >> >> 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. DS . 0