This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
why using acquire semantics in the atomic operations in pthread_mutex_unlock?
- From: "Chris Friesen" <cfriesen at nortel dot com>
- To: Ulrich Drepper <drepper at redhat dot com>, libc-alpha at sources dot redhat dot com
- Date: Thu, 09 Jul 2009 17:29:55 -0600
- Subject: why using acquire semantics in the atomic operations in pthread_mutex_unlock?
I'm trying to wrap my head around the memory barrier semantics in
pthread mutex operations.
I was under the impression that an unlock implies a write barrier, or
release semantics. This is borne out by the fact that for a regular
mutex we call lll_unlock() which for powerpc calls atomic_exchange_rel().
However, for priority inheritance or priority protection mutexes, the
unlock code path for the uncontended case ends up calling
atomic_compare_and_exchange_bool_acq(), which has acquire rather than
release semantics.
I assume I'm missing something--where is the write barrier for these cases?
Thanks,
Chris