From owner-cvs-all Thu Jul 5 11:18:12 2001 Delivered-To: cvs-all@freebsd.org Received: from sneakerz.org (sneakerz.org [216.33.66.254]) by hub.freebsd.org (Postfix) with ESMTP id 090CB37B403; Thu, 5 Jul 2001 11:18:08 -0700 (PDT) (envelope-from bright@sneakerz.org) Received: by sneakerz.org (Postfix, from userid 1092) id 732495D010; Thu, 5 Jul 2001 13:17:57 -0500 (CDT) Date: Thu, 5 Jul 2001 13:17:57 -0500 From: Alfred Perlstein To: Doug Rabson Cc: Matthew Jacob , John Baldwin , Matt Dillon , cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Jake Burkholder Subject: Re: cvs commit: src/sys/sys systm.h condvar.h src/sys/kern kern_ Message-ID: <20010705131757.E929@sneakerz.org> References: <20010705091047.C37950-100000@wonky.feral.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: ; from dfr@nlsystems.com on Thu, Jul 05, 2001 at 05:55:03PM +0100 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Doug Rabson [010705 11:56] wrote: > > Right. I'm not actually arguing for the existence of mwakeup() and > friends. I can't yet see any race window that they close when compared to > a code sequence which calls wakeup() followed by mtx_unlock(). It's not a race, it's just an optimization to avoid this happening. Thread A locks a mutex, Thread A determines it must wait for an event on the object protected by the mutex and calls msleep(), Thread B locks the mutex, Thread B fiddles a structure and calls wakeup on it to signal waiting 'A' that it can proceed. At this point there may be preemption, if Thread A now runs, it will immediately block on the mutex again because B hasn't released it. This is avoided with mwakeup(). However, I'm not much of a fan of wakeup() being a premption point. -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message