This is the mail archive of the
mailing list for the glibc project.
Question about the usage of pthread_mutex_t's __data.__lock
- From: Martin Galvan <martin dot galvan at tallertechnologies dot com>
- To: carlos at redhat dot com, Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, libc-alpha at sourceware dot org
- Date: Thu, 26 Feb 2015 18:08:57 -0300
- Subject: Question about the usage of pthread_mutex_t's __data.__lock
- Authentication-results: sourceware.org; auth=none
Hi everyone! I'm currently writing the gdb pretty-printers for some of
the NPTL types, as discussed here:
Right now I'm looking at the attributes of pthread_mutex_t, and I
noticed __data.__lock is used to signal the mutex being locked (or
not). For non-robust mutexes, according to sysdeps/nptl/lowlevellock.h
__lock can have three different values:
0: Not acquired.
1: Acquired with no waiters.
>1: Acquired, possibly with waiters.
Now, looking at __lll_lock_wait it seems that the ">1" value is
actually just 2 (i.e. we can't have 3, 4, etc). Am I missing
something, or should the comment be changed?
Speaking of which, I've found a couple of small mistakes in some
comments. For example:
while (atomic_exchange_acq (futex, 2) != 0)
lll_futex_wait (futex, 2, private); /* Wait if *futex == 2. */
That comment seems wrong to me since we'll be waiting if *futex == 1 too.
I was thinking of sending a patch to correct these mistakes. We have a
copyright assignment for gcc, gdb and binutils on the works; do we
need a separate one for glibc as well? Since the changes are
relatively small I don't think we need a copyright assignment for
Thanks a lot!
Taller Technologies Argentina
San Lorenzo 47, 3rd Floor, Office 5
Phone: 54 351 4217888 / +54 351 4218211