Re: pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow)

From: Nikita Danilov
Date: Thu Jan 26 2006 - 05:37:02 EST


Howard Chu writes:

[...]

>
> A straightforward reading of the language here says the decision happens
> "when pthread_mutex_unlock() is called" and not at any later time. There
> is nothing here to support your interpretation.
> >
> > I think the intention of the wording is that for deterministic policies,
> > it is clear that the waiting threads are actually worken and reevaluated
> > for scheduling. In the case of SCHED_OTHER, it means basically nothing,
> > considering the scheduling policy is arbitrary.
> >
> Clearly the point is that one of the waiting threads is waken and gets
> the mutex, and it doesn't matter which thread is chosen. I.e., whatever

Note that this behavior directly leads to "convoy formation": if that
woken thread T0 does not immediately run (e.g., because there are higher
priority threads) but still already owns the mutex, then other running
threads contending for this mutex will block waiting for T0, forming a
convoy.

> thread the scheduling policy chooses. The fact that SCHED_OTHER can
> choose arbitrarily is immaterial, it still can only choose one of the
> waiting threads.

Looks like a good time to submit Defect Report to the Open Group.

>
> The fact that SCHED_OTHER's scheduling behavior is undefined is not free
> license to implement whatever you want. Scheduling policies are an
> optional feature; the basic thread behavior must still be consistent
> even on systems that don't implement scheduling policies.
>
> --
> -- Howard Chu

Nikita.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/