From owner-freebsd-questions@FreeBSD.ORG Tue Mar 1 20:49:27 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6929816A4CE for ; Tue, 1 Mar 2005 20:49:27 +0000 (GMT) Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7936A43D48 for ; Tue, 1 Mar 2005 20:49:26 +0000 (GMT) (envelope-from scode@scode-whitestar.mine.nu) Received: from scode-whitestar.mine.nu ([83.226.138.147] [83.226.138.147]) by mxfep01.bredband.com with ESMTP <20050301204925.OFFY429.mxfep01.bredband.com@scode-whitestar.mine.nu>; Tue, 1 Mar 2005 21:49:25 +0100 Received: by scode-whitestar.mine.nu (Postfix, from userid 1001) id 0AE1117B90B; Tue, 1 Mar 2005 21:53:29 +0100 (CET) Date: Tue, 1 Mar 2005 21:53:29 +0100 From: Peter Schuller To: Jonathon McKitrick Message-ID: <20050301205328.GA22912@scode-whitestar.mine.nu> References: <20050227190842.GC34795@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050227190842.GC34795@dogma.freebsd-uk.eu.org> User-Agent: Mutt/1.5.8i cc: freebsd-questions@freebsd.org Subject: Re: Blocking on multiple threads with timeout X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Mar 2005 20:49:27 -0000 > I have a few threads that might need as long as a minute or more to > complete and terminate. If they exceed an arbitrary time, they can be > canceled. > > In Win32, there is a 'wait on multiple objects' call. I'm not sure if it > blocks or spins, but it *does* take a timeout argument. How about having the threads signal their completion explicitly while also signalling a condition. You could then have a monitoring thread using pthread_cond_timedwait() which would enable you to time out without busy-waiting. Cleanly killing the thread in question is another matter though... -- / Peter Schuller, InfiDyne Technologies HB PGP userID: 0xE9758B7D or 'Peter Schuller ' Key retrieval: Send an E-Mail to getpgpkey@scode.org E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org