This is the mail archive of the libc-alpha@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]

Re: Synchronizing auxiliary mutex data


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?


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