Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 08 Jul 2001 00:34:55 -0400
From:      Sergey Babkin <babkin@bellatlantic.net>
To:        Greg Lehey <grog@FreeBSD.org>
Cc:        Matt Dillon <dillon@earth.backplane.com>, Alfred Perlstein <bright@sneakerz.org>, "Justin T. Gibbs" <gibbs@scsiguy.com>, John Baldwin <jhb@FreeBSD.org>, Jake Burkholder <jake@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org, Matthew Jacob <mjacob@feral.com>, Doug Rabson <dfr@nlsystems.com>
Subject:   Re: cvs commit: src/sys/sys systm.h condvar.h src/sys/kern kern_
Message-ID:  <3B47E2EF.3022DF3F@bellatlantic.net>
References:  <XFMail.010705123747.jhb@FreeBSD.org> <200107052228.f65MSeU64741@aslan.scsiguy.com> <20010705174135.A79818@sneakerz.org> <200107060214.f662ElT61708@earth.backplane.com> <20010708110449.E75626@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Lehey wrote:
> 
> >> Y'know this sorta got me thinking about something else, shouldn't the
> >> wakeup() calls for most exclusive locks use wakeup_one?  I know
> >> wakeup_one() hoses priority, but for the locks in things like vnodes
> >> and the pager locks, shouldn't we do a wakeup_one() since it is an
> >> exclusive lock?
> >>
> >> --
> >> -Alfred Perlstein [alfred@freebsd.org]
> >
> >     I would not recommend using wakeup_one until 5.2ish.  A mistake could
> >     result in hard-to-find system lockups.
> 
> I would not recommend using wakeup_one.  It has the potential to hang
> the system.
> 
> One of the tradeoffs in the sleep/wakeup paradigm is that you wait on
> an arbitrary address.  This works fine as long as you wake up *every*
> process.  But consider two independent subsystems which wait on the
> same address.  wakeup_one wakes the first waiter on the list, which
> happens to belong to the other subsystem.  It checks its environment
> and goes back to sleep.  Bingo!  The first subsystem has lost a
> wakeup.

Hm, my understanding is that the intended "standard" way of using the 
likes of wakeup_one (such as sVr4.mp condition variable non-broadcast
signalling) is that after the woken up process/thread completes its 
work it _must_ check if anybody else is sleeping on the same 
condition and wake up the next sleeper. The idea is that the
conditional variable protects a resource that may only be used
by one process at a time, so to avoid waking up all the potential
herd of sleeping processes only to get all of them but one to check 
the condition and go to sleep again, only one process is woken up 
at a time, and after it's done it must wake up the next one. I'd say 
that any other use of such non-broadcast wakeup is probably bogus.

-SB

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B47E2EF.3022DF3F>