From owner-freebsd-arch@FreeBSD.ORG Sun Mar 5 13:36:36 2006 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E041C16A420 for ; Sun, 5 Mar 2006 13:36:36 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9181B43D48 for ; Sun, 5 Mar 2006 13:36:36 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 1E2D646C00; Sun, 5 Mar 2006 08:36:13 -0500 (EST) Date: Sun, 5 Mar 2006 13:36:33 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Poul-Henning Kamp In-Reply-To: <35339.1141557488@critter.freebsd.dk> Message-ID: <20060305133516.P51568@fledge.watson.org> References: <35339.1141557488@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@freebsd.org Subject: Re: wakeup idea... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Mar 2006 13:36:37 -0000 On Sun, 5 Mar 2006, Poul-Henning Kamp wrote: > Here is a possibly stupid idea. > > Historically sleep/wakeup have happened on a pointer which was just a magic > number. > > In many cases, this pointer is actually a relevant datastructure. > > Would it possibly be an optimization to make a variant of the sleep/wakeup > calls where the pointer points to an integer type which contains non-zero if > anybody is actually sleeping on that address ? > > Anybody up for a quick prototype ? In principle this is part of the point of a condition variable, which associates a struct with waitable conditions, and includes an int that contains the number of waiters: struct cv { const char *cv_description; int cv_waiters; }; Presumably the tricky bit is optimizing this such that you avoid undesirable races. (But maybe if you call cv_signal without the condition mutex held, you accept that race by definition?) Robert N M Watson