Subj : Re: Memory visibility and synchronization using pipes To : comp.programming.threads From : Marcin 'Qrczak' Kowalczyk Date : Thu Jan 20 2005 12:05 am David Hopwood writes: >>>> Is it safe, or the change to the variable may not be seen by the other >>>> thread? I guess write() and poll() are not memory barriers and this is >>>> unsafe. [...] > Yes, but the OP asked what was "safe". Alexander's answer is a reasonable > one, not just from a technical standards compliance point of view but also > for writing real pthreads programs. [...] Thanks for answers. Actually, since I needed it only to signal that a thread has finished its work, after synchronizing using a pipe the calling thread does pthread_join, and then accesses the shared variables. This is definitely safe. The problem would reappear if I used a thread pool. Then I would probably have to add "empty" locking and unlocking of a mutex: before synchronization by pipe in the producer, and after synchronization in the consumer. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ .