Synchronizing auxiliary mutex data
Torvald Riegel
triegel@redhat.com
Mon Jun 19 18:25:00 GMT 2017
On Mon, 2017-06-19 at 10:10 +0200, Andreas Schwab wrote:
> What is synchronizing the auxiliary data in pthread_mutex_t.__data
> (__owner and __count) between threads?
__owner accesses need to use atomics (which they don't, currently).
Relaxed MO is fine I believe:
* We write to __owner only when in the critical section, with relaxed
MO; we write TID after lock and 0 before unlock. Those writes are
ordered by the critical section.
* There are reads outside of the critical sections, but those need to
read-from either the most recent (in modification order) store by the
same thread, or a more recent store by another thread; so, you can't
read your TID unless you're in the critical section because if you are
not, you will read 0 or another TID.
__count is only accessed within the critical section IIRC.
Is that what you were asking about?
More information about the Libc-alpha
mailing list