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]

Question about the usage of pthread_mutex_t's __data.__lock


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


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