Subj : Re: Memory visibility and synchronization using pipes To : comp.programming.threads From : Joseph Seigh Date : Sat Jan 15 2005 11:02 am On Sat, 15 Jan 2005 16:34:49 +0100, Alexander Terekhov wrote: > > Marcin 'Qrczak' Kowalczyk wrote: > [...] >> Is it safe, or the change to the variable may not be seen by the other > > It is "unsafe". You have a data race. Undefined behavior. > >> thread? I guess write() and poll() are not memory barriers and this is >> unsafe. > > Even if they do have memory barriers internally, compiler is > not constrained and can reorder you accesses across write() > and poll(). They both are standard functions and they are NOT > listed in the XBD 4.10. Technically, all threaded programming in C is undefined. That includes Posix pthreads since it is incomplete with respect to thread behavior and it has no formal definition of its semantics. About the only functions you can argue argue that C can optimize across are C intrinsics and maybe functions declared with compiler specific pragmas. -- Joe Seigh .