Re: [patch 00/15] Generic Mutex Subsystem

From: Oleg Nesterov
Date: Wed Jan 11 2006 - 03:04:38 EST


Balbir Singh wrote:
>
> On Tue, Jan 10, 2006 at 09:03:07PM +0300, Oleg Nesterov wrote:
>
> > I don't have an answer, only a wild guess.
> >
> > Note that if P1 releases this semaphore before pre-woken P2 actually
> > gets cpu what happens is:
> >
> > P1->up() just increments ->count, no wake_up() (fastpath)
> >
> > P2 takes the semaphore without schedule.
> >
> > So *may be* it was designed this way as some form of optimization,
> > in this scenario P2 has some chances to run with sem held earlier.
> >
>
> P1->up() will do a wake_up() only if count < 0. For no wake_up()
> the count >=0 before the increment. This means that there is no one
> sleeping on the semaphore.

And this exactly happens. P1 returns from __down() with ->count == 0
and P2 pre-woken.

Oleg.
-
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/