From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 31 03:16:45 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6171A16A4CE for ; Wed, 31 Dec 2003 03:16:45 -0800 (PST) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2AB7943D1D for ; Wed, 31 Dec 2003 03:16:43 -0800 (PST) (envelope-from marcolz@stack.nl) Received: from toad.stack.nl (zen.stack.nl [2001:610:1108:5010::130]) by mailhost.stack.nl (Postfix) with ESMTP id 3FF2B01A#857DF1F04D for ; Wed, 31 Dec 2003 12:16:42 +0100 (CET) Received: by toad.stack.nl (Postfix, from userid 333) id 652DA97; Wed, 31 Dec 2003 12:16:42 +0100 (CET) Date: Wed, 31 Dec 2003 12:16:42 +0100 From: Marc Olzheim To: hackers@freebsd.org Message-ID: <20031231111642.GA13386@stack.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD toad.stack.nl 4.9-RC FreeBSD 4.9-RC X-URL: http://www.stack.nl/~marcolz/ User-Agent: Mutt/1.5.5.1i Subject: libc_r/uthread/uthread_join.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2003 11:16:45 -0000 Hi. Is there a reason why in the case that a thread is not done yet, pthread_join() does not call _thread_kern_sig_undefer() ? We have a program where one thread consumes all CPU it can get for blocks of data. A status thread is spawned as soon as the main thread starts working on a new block, printing an 'x % done' message and sleeping for a second in a loop. When the block is processed, the status thread is pthread_cancel()d and the main thread does a pthread_join() to wait for the status thread to exit. Now, when the second block is to be processed, a new status thread is spawned, but since signals are still defered and the main thread needs all the cpu it can get, it doesn't get scheduled in anymore. The following fixed the problem in 4-STABLE and it seems to work ok, but I'm no sure if there was a reason for the omission of the call in that case... --- uthread_join.c Tue Oct 22 16:44:03 2002 +++ uthread_join.c.fixed Wed Dec 31 12:12:33 2003 @@ -136,6 +136,9 @@ ret = curthread->join_status.error; if ((ret == 0) && (thread_return != NULL)) *thread_return = curthread->join_status.ret; + + /* Undefer and handle pending signals, yielding if necessary: */ + _thread_kern_sig_undefer(); } else { /* * The thread exited (is dead) without being detached, and no Zlo