"memory" clobber in synchronization primitives

Wolfram Gloger wmglo@dent.med.uni-muenchen.de
Tue Sep 1 02:49:00 GMT 1998


> It is not particularly clear to me from 1003.1-1996 whether
> pthread_mutex_lock et al are expected to be explicit memory barriers
> obviating the need for `volatile'-qualified reads.

David Butenhof's `Programming with POSIX threads' (if I read it
correctly) makes it abundantly clear that mutexes _are_ explicit
memory barriers.  Further, it mostly discourages the use of `volatile'
in threaded code, because by itself `volatile' doesn't guarantee any
ordering of memory accesses, at least on modern multiprocessor
architectures.

Regards,
Wolfram.
-- 
`Surf the sea, not double-u three...'
wmglo@dent.med.uni-muenchen.de



More information about the Libc-hacker mailing list