Subj : Re: Avoiding synchronization (pthreads) To : comp.programming.threads From : Marcin 'Qrczak' Kowalczyk Date : Wed Mar 02 2005 10:58 pm "Joe Seigh" writes: >> Yes. Are there architectures where one thread decrementing an int can >> cause another thread which doesn't use a memory barrier see the value >> which has nothing to do with the actual range of values of this int? > > You need the barrier to prevent reads of the shared data occuring before > the fetch of the count. You only need to do it once after seeing the > count go to one thread. Kind of like DCL but with multiple initializers. Ah, I think I understand. I fixed the code to have a cache of this variable accessed outside the mutex by a single thread, updated from the real variable inside the mutex. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ .