This is the mail archive of the
mailing list for the glibc project.
Does pthread_mutex_lock/unlock require and imply a memory barrier for all addressable memory?
- From: Chip Bagwell <chip dot bagwell at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Mon, 7 Jul 2014 11:33:40 -0500
- Subject: Does pthread_mutex_lock/unlock require and imply a memory barrier for all addressable memory?
- Authentication-results: sourceware.org; auth=none
Dear glibc-help community,
In reading the POSIX 2008 standards found here,
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!--