Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : David Schwartz Date : Fri May 27 2005 03:50 pm "Chris Thomasson" <_no_damn_spam_cristom@_no_damn_comcast.net_spam> wrote in message news:v5GdnY0GxZ9NDQrfRVn-iA@comcast.com... >> Sadly, the word "atomic" is used several different ways. > > OK. Here is a very simple question... > > > static int shared = 0; > > > CPU A > -------- > > for ( ;; ) > { > shared = 1; > } > CPU B > -------- > > for ( ;; ) > { > int local = shared; > > assert( local == 0 || local == 1 ); > } > How many existing processors today could trip the assertion? In principle, any of them. There is nothing illegal about the compiler implementing the CPU A loop as, in pseudo-code: shared+=5; usleep(1); shared=1; It would violate no standard at all. In practice, it is hard to imagine any existing processor compiler could actually trip that assertion. However, it would be foolish to rely on it. DS .