Date: Sun, 5 Mar 2006 13:36:33 +0000 (GMT) From: Robert Watson <rwatson@FreeBSD.org> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: arch@freebsd.org Subject: Re: wakeup idea... Message-ID: <20060305133516.P51568@fledge.watson.org> In-Reply-To: <35339.1141557488@critter.freebsd.dk> References: <35339.1141557488@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060305133516.P51568>