Subject: Re: use of wakeup_one by kern_lock.c vs. mixed shared/exclusive locks..
To: Jaromír Dolecek <jdolecek@netbsd.org>
From: Darren Reed <darrenr@reed.wattle.id.au>
List: tech-kern
Date: 09/30/2001 22:21:47
In some email I received from Jarom=EDr Dolecek, sie wrote:
> Darren Reed wrote:
> > > Moreover, doing a wakeup_one() when there are multiple *readers*
> > > waiting doesn't make any sense; it would seem that the only time
> > > wakeup_one() would be safe is if a lock is *only* used exclusively.
> >=20
> > Is there something we can do to code this rule into place ?
> >=20
> > For example, make wakeup_one() panic when it sees this condition, or
> > automatically call wakeup() instead, maybe ?
>=20
> wakeup_one() exits as soon as it sees (and awakens) first process
> with matching ident. It's a speedy wakeup() when you know there is
> only one process waiting on the channel.
>=20
> It's my understanding the right answer is to either restructure
> the code so that indeed there would be just one waiter (or the
> awakened process would awaken others), or use wakeup().
Maybe I should rephrase what I was saying.
Kernel code compiled with DIAGNOSTIC (DEADLOCKDEBUG?) or similar should
include extra code that checks for programming mistakes like these at
run time and panic's the box.
If Bill can make this sort of programming mistake then I'm sure others
will too - and they may not even be developers.
Darren