Subj : Re: Memory synchronization with pthreads To : comp.programming.threads From : Alexander Terekhov Date : Mon Jan 17 2005 10:12 am Chris Vine wrote: [... pipes ...] > I was wondering whether one of the threads making a > (otherwise meaningless) call to sem_post() to a (otherwise unnecessary) > semaphore in one of the threads would do this without the other thread > having to do anything special. No. ----- Applications shall ensure that access to any memory location by more than one thread is restricted such that no thread can read or modify a memory location while another thread of control may be modifying it. Applications shall use functions listed below that synchronize thread execution and ensure that modifications to locations in memory are ordered with respect to accesses to the same memory locations in other threads. There is a happens-before inter-thread ordering with respect to preceding (in program and inter-thread order) modifications of memory locations in [...] a thread calling sem_post() on a specified semaphore and accesses to modified memory locations in another thread after that thread calls sem_wait() or sem_trywait() or sem_timedwait() and locks the same semaphore unlocked by the calling thread, or another thread observes the incremented semaphore value of the same semaphore by calling sem_getvalue(); ----- Note that sem_getvalue() is currently NOT listed in the XBD 4.10. > Perhaps a (otherwise meaningless) fork() > would do this? No. regards, alexander. .