Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Jul 2001 14:33:03 +0930
From:      Greg Lehey <grog@FreeBSD.org>
To:        Sergey Babkin <babkin@bellatlantic.net>
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:  <20010708143303.Z80862@wantadilla.lemis.com>
In-Reply-To: <3B47E2EF.3022DF3F@bellatlantic.net>; from babkin@bellatlantic.net on Sun, Jul 08, 2001 at 12:34:55AM -0400
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> <3B47E2EF.3022DF3F@bellatlantic.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday,  8 July 2001 at  0:34:55 -0400, Sergey Babkin wrote:
> 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.

Hmm.  But I haven't seen that documented anywhere.  It also places the
responsibility in the wrong place IMO.

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

The problem is that you need to choose your condition pretty
carefully.  I suppose that's possible.  I haven't thought it through
yet.

Greg
--
See complete headers for address and phone numbers

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?20010708143303.Z80862>