On Sun, Oct 28, 2007 at 06:06:17PM -0000, Dave Korn wrote: > On 28 October 2007 17:39, Erik Trulsson wrote: > > > On Sun, Oct 28, 2007 at 01:10:00PM -0400, Robert Dewar wrote: > >> Erik Trulsson wrote: > >> > >>> Unfortunately it seems that the POSIX standard for threads say that as > >>> long as access to a shared variable is protected by a mutex there is no > >>> need to use 'volatile'. > >> > >> How does it say this, in some semantically precise way, or with hand > >> waving as in this sentence. > > > > I don't know. I don't have access to the POSIX standard itself so I have > > to depend on other peoples description of what POSIX says. (Thus my use of > > 'seems' above.) > > Everything I have found seem to agree that POSIX does not require the use of > > volatile though. > > As far as I know, there is no separate 'pthreads' spec apart from what is > defined in the Threads section (2.9) of the SUS (http://tinyurl.com/2wdq2u) > and what it says about the various pthread_ functions in the system interfaces > (http://tinyurl.com/2r7c5k) chapter. None of that, as far as I have been able > to determine, makes any kind of claims about access to shared state or the use > of volatile.
Having just been pointed to that copy of the SUS, I must agree. I can't find anything in there saying anything at all about what is required to safely share data between threads. If that is really so it seems 'pthreads' are even more under-specified than I thought (and I had fairly low expectations in that regard.) I really hope there is something I have missed. -- <Insert your favourite quote here.> Erik Trulsson [EMAIL PROTECTED]