This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Question about the usage of pthread_mutex_t's __data.__lock
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Martin Galvan <martin dot galvan at tallertechnologies dot com>, Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, libc-alpha at sourceware dot org, Torvald Riegel <triegel at redhat dot com>
- Date: Fri, 27 Feb 2015 16:30:01 -0500
- Subject: Re: Question about the usage of pthread_mutex_t's __data.__lock
- Authentication-results: sourceware.org; auth=none
- References: <CAOKbPbZr1oGug7y_=OGSq2P9jLMk8zOqu6+eShrQV1rRqkyrsw at mail dot gmail dot com>
On 02/26/2015 04:08 PM, Martin Galvan wrote:
> 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.
Correct.
> 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?
The specification is correct, but purposely vague, it likely comes
from a time when we didn't want to say that "2" was the only possible
value.
Adding Torvald to the TO:.
Torvald, Do you know of any reason why we wouldn't just document
in comments that 2 means `acquired, possibly with waiters` instead
of saying >1?
> 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'll let Torvald answer that.
> 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.
For a few changes here and there you don't need copyright assignment,
roughly 11 lines is the metric we use to determine if you need one or not.
I would suggest getting one if you want to seriously contribute now and
in the future.
Cheers,
Carlos.