This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Does pthread_mutex_lock/unlock require and imply a memory barrier for all addressable memory?


Dear glibc-help community,

In reading the POSIX 2008 standards found here,

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11,

the following paragraph is written regarding memory synchronization.

"Applications shall ensure that access to any memory location by more
than one thread of control (threads or processes) is restricted such
that no thread of control can read or modify a memory location while
another thread of control may be modifying it. Such access is
restricted using functions that synchronize thread execution and also
synchronize memory with respect to other threads. The following
functions synchronize memory with respect to other threads:"

I read the "synchronize memory with respect to other threads" to mean
that a memory barrier is required in both pthread_mutex_lock() and
pthread_mutex_unlock() along with the other mentioned functions in the
standard.  Otherwise what would be protecting the data
structures/variables you are trying to access/modify inside the
critical section protected by the mutex?

Am I missing something that is leading me to the wrong interpretation
of the POSIX standard?

Thanks in advance!--

Chip Bagwell
chip.bagwell@gmail.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]