Re: mutexs for synchronization between kernel threads?

V Ganesh (ganesh@vxindia.veritas.com)
Thu, 22 Apr 1999 23:00:04 +0530 (IST)


> From: Andi Kleen <ak@muc.de>
>
> Patrick MOUROT <pm@sxb.bsf.alcatel.fr> writes:
> >
> > Sorry for disturbing....but i have a hot (at least for us) question :
> > Do you encounter any Priority Inversion or deadlock with Mutexes or
> > Semaphores (regarding to spinlock) ??
>
> AFAIK Linux 2.2 makes no attempt to handle priority inversion in any
> locking code. so yes. Deadlocks are always easy with any locking
> primitives.

well semaphores seem to make an attempt at least. when an "up" is done on
a semaphore, the "waking" field is incremented by 1 and _all_ the processes
waiting on the semaphore are woken up. they race to decrement "waking" and
the process which wins owns the semaphore now. who wins the race depends
on who the scheduler picks to run first, which depends on priority among
other things. so the highest priority process has a good chance of getting
the semaphore. doesn't this solve the inversion problem somewhat ?
(there are other issues due to which we can't just wake a single process
and avoid the thundering herd. for one thing, these primitives don't take
the process off the wait queue when they wake it up. they rely on the
process itself to do so. so queue management becomes a bit more complex when
multiple "up"s arrive before any of the woken up processes run and take
themselves off the queue.)
someone please yell if I'm totally off the mark...

ganesh

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