From owner-freebsd-arch@FreeBSD.ORG Mon Mar 31 13:05:46 2003 Return-Path: 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 69E5337B404 for ; Mon, 31 Mar 2003 13:05:46 -0800 (PST) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id B928F43FAF for ; Mon, 31 Mar 2003 13:05:45 -0800 (PST) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.12.9/8.12.9) with SMTP id h2VL66YY013318; Mon, 31 Mar 2003 16:06:06 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Mon, 31 Mar 2003 16:06:06 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Andrew Gallatin In-Reply-To: <16008.30029.620721.433243@grasshopper.cs.duke.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-arch@freebsd.org Subject: Re: cv_timedwait() & exiting procs X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Mar 2003 21:05:47 -0000 On Mon, 31 Mar 2003, Andrew Gallatin wrote: > FreeBSD's cv_timedwait() function helpfully notices that a process is > exiting and returns EWOULDBLOCK if it is. > > However, if you call cv_timedwait() in the context of a process which is > already exiting, you always get back EWOULDBLOCK, regardless of whether > or not the timeout expired. Similarly for the cv_wait_sig() and > cv_timedwait_sig(), except they set EINTR. > > Does anyone else consider this behaviour to be a bug? I think it should > only return EWOULDBLOCK/EINTR because a process is exiting if the > process wasn't already exiting when it entered the cv_*wait* routine, > but perhaps I'm misguided... Hmm. It has always struck me that the nice thing about the SMPng synchronization primitives is that they implement well-defined anc consistent semantics in a manner consistent with other implementations of the same primitives. I'd rather see the caller test the P flags and change the arguments to cv_timedwait() than see cv_timedwait() implement unusual semantics based on process conditions. Process exiting stuff is a special case, but only from the perspective of the high level code: I think I'd be upset to find cv_timedwait() change behavior at a much lower level (i.e., in vnode handling or last reference socket handling) just because it happens to run at exit()-time. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Network Associates Laboratories