This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Race unlocking-locking mutex
- From: Godmar Back <godmar at gmail dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: Rich Felker <dalias at aerifal dot cx>, "Carlos O'Donell" <carlos at systemhalted dot org>, David Ahern <dsahern at gmail dot com>, "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Fri, 13 Sep 2013 15:31:40 -0400
- Subject: Re: Race unlocking-locking mutex
- Authentication-results: sourceware.org; auth=none
- References: <5231ECBE dot 4030006 at gmail dot com> <CAB4+JY+dBDVhk9UJWXRXrxF5BhoTFXv==_v+ibdEBU5Noj4aEw at mail dot gmail dot com> <5231F2C3 dot 6080305 at gmail dot com> <CAE2sS1gp9Z5b5qoSqgBXbbL-S+_fHaL1PN7z=CfMsqSTA=7LFg at mail dot gmail dot com> <CAB4+JY++Zs_kKN32oWKvy1i-HQOHZQsosBSUBc3=YrXA_S96Hw at mail dot gmail dot com> <523349A3 dot 7000501 at redhat dot com> <CAB4+JYLZ5ayNWD8UmfhF51v112LfuJQLUUf1CH4eKdesgRHNsA at mail dot gmail dot com> <52336554 dot 2090406 at redhat dot com>
On Fri, Sep 13, 2013 at 3:19 PM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 09/13/2013 01:33 PM, Godmar Back wrote:
>> The standard says:
>> "The need to hold spin lock overhead to an absolute minimum also
>> makes it impossible to provide guarantees against starvation similar
>> to those provided for mutexes or read-write locks."
>>
>> What starvation guarantees are they talking about? I thought it meant
>> that an implementation is required to use a FIFO policy if multiple
>> SCHED_RR/SCHED_FIFO threads of *equal* priority are queued on a
>> contended lock.
>>
>> But I also haven't been able to find it explicitly saying so.
>
> I've never seen any guarantees against starvation.
>
> Rich,
>
> Including you here to pick your brain. Has POSIX ever guaranteed
> that mutexes or read-write locks are free of starvation?
>
There are a number of references in the standard & rationale.
Searching for 'starvation', I find for instance
"The need to hold spin lock overhead to an absolute minimum also makes
it impossible to
provide guarantees against starvation similar to those provided for
mutexes or read-write
locks."
But it's not clear at all which guarantees they're referring to.
In the context of rw locks:
"to prevent writer starvation from threads of the same or lower
priority, writers take precedence over readers of the same or lower
priority"
but in the actual section it says only:
"Implementations may favor writers over readers to avoid writer starvation."
> Cheers,
> Carlos.
>
> P.S.
>
> Please avoid top-posting, it's not the common practice here.
> We use bottom/inline posting with trimming as appropriate to make
> the point clear.
>