Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Dec 1998 00:09:58 -0800 (PST)
From:      Archie Cobbs <archie@whistle.com>
To:        dillon@apollo.backplane.com (Matthew Dillon)
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: asleep()/await(), M_AWAIT, etc...
Message-ID:  <199812190809.AAA27615@bubba.whistle.com>
In-Reply-To: <199812170805.AAA89361@apollo.backplane.com> from Matthew Dillon at "Dec 17, 98 00:05:29 am"

next in thread | previous in thread | raw e-mail | index | archive | help
Matthew Dillon writes:
>     We add an asleep() kernel function to complement tsleep().  asleep()
>     works like tsleep() in that it adds the process to the appropriate
>     slpque, but asleep() does *not* put the process to sleep.  Instead it
>     returns immediately.  The process stays runnable.  Additional calls
>     to asleep() (or a call to tsleep()) removes the proc from any slpque
>     and re-adds it to the new one.  i.e. only the most recent call is
>     effective.
> 
>     We add an await() kernel function.  This function initiates any timeout
>     and puts the process to sleep, but only if it is still on a sleep queue.
>     If someone (i.e. an interrupt) wakes up the sleep address after the
>     process calls asleep() but before it calls await(), the slpque is
>     cleared and the await() winds up being a NOP.

Hmm.. sounds interesting. Seems like one problem is that most
function calls have the semantics that they don't return until
the job they are supposed to do is finished. This would change.

So you would have to adjust all the upper layer functions to take
account of this change in semantics (they'd have to know to call
await() at the least, of course).

Also, this only works once; you can't call two subroutines
in a row that both call asleep(), because the second asleep()
will erase the first.

But in certain cases where you don't need to hold a lock for
the duration of the lengthy operation it would definitely help
reduce contention.

It would be interesting to see a list of specific cases where
this could be used and would make a significant difference.

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812190809.AAA27615>