Question about the usage of pthread_mutex_t's __data.__lock

Martin Galvan martin.galvan@tallertechnologies.com
Thu Feb 26 21:09:00 GMT 2015


Hi everyone! I'm currently writing the gdb pretty-printers for some of
the NPTL types, as discussed here:

https://sourceware.org/ml/libc-alpha/2015-02/msg00194.html

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
those, though.

Thanks a lot!

-- 

Martín Galván

Software Engineer

Taller Technologies Argentina

San Lorenzo 47, 3rd Floor, Office 5

Córdoba, Argentina

Phone: 54 351 4217888 / +54 351 4218211



More information about the Libc-alpha mailing list