From owner-freebsd-arch@FreeBSD.ORG Mon Mar 31 12:51:00 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 8D6A337B435 for ; Mon, 31 Mar 2003 12:51:00 -0800 (PST) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC01F43FB1 for ; Mon, 31 Mar 2003 12:50:59 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 16395 invoked from network); 31 Mar 2003 20:51:04 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 31 Mar 2003 20:51:04 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.8/8.12.8) with ESMTP id h2VKojOv016783; Mon, 31 Mar 2003 15:50:47 -0500 (EST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <16008.30029.620721.433243@grasshopper.cs.duke.edu> Date: Mon, 31 Mar 2003 15:50:46 -0500 (EST) From: John Baldwin To: Andrew Gallatin 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 20:51:01 -0000 On 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... I think you are referring to these changes? revision 1.23 date: 2002/06/29 17:26:18; author: julian; state: Exp; lines: +76 -13 Part 1 of KSE-III The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals.. Things like: @@ -293,6 +328,8 @@ rval = ERESTART; } PROC_UNLOCK(p); + if (p->p_flag & P_WEXIT) + rval = EINTR; #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -363,6 +400,8 @@ mi_switch(); } + if (td->td_proc->p_flag & P_WEXIT) + rval = EWOULDBLOCK; mtx_unlock_spin(&sched_lock); #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) @@ -450,6 +488,9 @@ } PROC_UNLOCK(p); + if (p->p_flag & P_WEXIT) + rval = EINTR; + #ifdef KTRACE if (KTRPOINT(td, KTR_CSW)) ktrcsw(0, 0); I guess this has something to do with single threading? If so it seems broken since it should only affect the singlethreading case while you are actually doing singlethreading. Maybe Julian can help fix it? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/