Subj : Re: Consistency of a byte shared variable To : comp.programming.threads From : SenderX Date : Mon Jan 31 2005 11:49 pm DOH, Sorry for the last post!. Anyway... >> POSIX, > > POSIX requires locks around all accesses to shared variables. See the > POSIX memory visibility rules. Does POSIX guarantee that the following scenario will be correct? // shared vars int s1 = 0; int s2 = 0; int s3 = 0; int s4 = 0; int s5 = 0; // shared semaphore sem_t flag; /* val = 0 */ // Thread A A1: s1 = 1; A2: s2 = 2; A3: s3 = 3; A4: s4 = 4; A5: s5 = 5; sem_post( &flag ); // Thread B B1: sem_wait( &flag ); B2: int test = s1 + s2 + s3 + s4 + s5; B3: if ( test != 15 ) { abort(); } Could the example "ever" abort in B3 under the POSIX memory visibility rules? .