From owner-freebsd-threads@FreeBSD.ORG Tue Apr 27 06:47:11 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6FD9216A4CE for ; Tue, 27 Apr 2004 06:47:11 -0700 (PDT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A2C943D39 for ; Tue, 27 Apr 2004 06:47:11 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 21803 invoked from network); 27 Apr 2004 13:47:10 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 27 Apr 2004 13:47:10 -0000 Received: from slimer.baldwin.cx (slimer.baldwin.cx [192.168.0.16]) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i3RDknLG007021; Tue, 27 Apr 2004 09:47:08 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: Daniel Eischen Date: Tue, 27 Apr 2004 09:47:08 -0400 User-Agent: KMail/1.6 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200404270947.08523.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: threads@FreeBSD.org cc: David Xu Subject: Re: kse_release and kse_wakeup problem (fwd) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2004 13:47:11 -0000 On Monday 26 April 2004 01:38 pm, Daniel Eischen wrote: > On Mon, 26 Apr 2004, Daniel Eischen wrote: > > On Mon, 26 Apr 2004, David Xu wrote: > > > John Baldwin wrote: > > > > I.e. do the upcall check in sleepq_catch_signals() right where you > > > > already do thread_suspend_check(1). The only reason you have to do > > > > this, btw, is because the kse_release() code is trying to mess with > > > > thread state internals using sleepq_abort(), etc. The other > > > > in-kernel code that does that (signals) already does the check in > > > > sleepq_catch_signals() and has done the same type of check in > > > > msleep()/tsleep() for quite a while. > > > > > > > > If the kse_release() stuff was just using sleep/wakeup() rather than > > > > trying to manually abort sleeps it wouldn't have to be so intimate > > > > with the sleep interface. > > > > > > > > Note that thr's thr_wakeup() and thr_sleep() manage to simulate > > > > synchronization w/o having to abort sleeps, but it is probably also > > > > easier to do that than for the M:N case. > > > > > > I think libthr will encounters same problem as libpthread with new > > > sleep queue code, because mtx is released too early in msleep before > > > thread markes itself as ON_SLEEPQ, thr_suspend and thr_wakeup have same > > > race window as kse_release and kse_wakeup. Any code wants to put > > > synchronous bit in td_flags like these codes will be broken. > > > > I'm experimenting with adding an wakeup_thread() to kern_thread.c > > (to complement wakeup() and wakeup_one()). If we shouldn't be > > using sleepq's directly, the thread code either needs to > > > > a) queue msleep()'ing upcalls/threads itself having them > > all block on on their own unique wchan's; or > > > > b) use a wakeup_thread() that wakes up a specific thread. > > Sorry, patch for b) is at: > > http://people.freebsd.org/~deischen/sys.diffs Erm, does sleepq_signal_thread() do anything different than sleepq_remove() (removes a thread from a specified wait channel if and only if the thread is sleeping on that wait channel)? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org