From owner-freebsd-current Sat Dec 19 00:11:00 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA10982 for freebsd-current-outgoing; Sat, 19 Dec 1998 00:11:00 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA10974 for ; Sat, 19 Dec 1998 00:10:56 -0800 (PST) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id AAA14887; Sat, 19 Dec 1998 00:10:24 -0800 (PST) Received: from bubba.whistle.com( 207.76.205.7) by whistle.com via smap (V2.0) id xma014875; Sat, 19 Dec 98 00:09:58 -0800 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id AAA27615; Sat, 19 Dec 1998 00:09:58 -0800 (PST) From: Archie Cobbs Message-Id: <199812190809.AAA27615@bubba.whistle.com> Subject: Re: asleep()/await(), M_AWAIT, etc... In-Reply-To: <199812170805.AAA89361@apollo.backplane.com> from Matthew Dillon at "Dec 17, 98 00:05:29 am" To: dillon@apollo.backplane.com (Matthew Dillon) Date: Sat, 19 Dec 1998 00:09:58 -0800 (PST) Cc: freebsd-current@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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