From owner-freebsd-arch Wed Jan 17 11:42:32 2001 Delivered-To: freebsd-arch@freebsd.org Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88]) by hub.freebsd.org (Postfix) with ESMTP id 3565337B6A8 for ; Wed, 17 Jan 2001 11:42:05 -0800 (PST) Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241]) by meow.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id f0HJe4L39662; Wed, 17 Jan 2001 11:40:04 -0800 (PST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20010117112850.X7240@fw.wintelcom.net> Date: Wed, 17 Jan 2001 11:41:58 -0800 (PST) From: John Baldwin To: Alfred Perlstein Subject: Re: HEADS-UP: await/asleep removal imminent Cc: arch@FreeBSD.org, Matt Dillon Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 17-Jan-01 Alfred Perlstein wrote: > > Jason Evans just added his conditional variables, you could change > asleep/await into cv_attach/cv_await or something, that would give > you less contention on the sleep/run queues, but you'd still need > a spinlock or mutex on these variables. A condvar already contains the state information that asleep() caches in p_aleep right now, so just passing condvar pointers around would accomplish this task using an existing API and is conceptually cleaner: int my_lowlevel_func(struct cv **cv) { if (bad_things) { *cv = &my_condition; return (some_error); } *cv = NULL; return (0); } ... struct cv *cv; ... if (my_lowlevel_func(&cv) != 0) { KASSERT(cv != NULL, (__FUNCTION__ ": nothing to sleep on!")); cv_wait(cv); } -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message