From owner-freebsd-current Wed Aug 5 15:57:48 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA09341 for freebsd-current-outgoing; Wed, 5 Aug 1998 15:57:48 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from cimlogic.com.au (cimlog.lnk.telstra.net [139.130.51.31]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA09326 for ; Wed, 5 Aug 1998 15:57:43 -0700 (PDT) (envelope-from jb@cimlogic.com.au) Received: (from jb@localhost) by cimlogic.com.au (8.8.8/8.8.7) id JAA28909; Thu, 6 Aug 1998 09:02:19 +1000 (EST) (envelope-from jb) From: John Birrell Message-Id: <199808052302.JAA28909@cimlogic.com.au> Subject: Re: Pthreads woes In-Reply-To: <19980805180913.10635@kublai.com> from Brian Cully at "Aug 5, 98 06:09:13 pm" To: shmit@kublai.com Date: Thu, 6 Aug 1998 09:02:19 +1000 (EST) Cc: current@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Brian Cully wrote: > I'm working on a program that spawns a bunch of threads in a pool, each > of which sits on a condition variable. The main thread waits for > a RADIUS request on a socket, it signals the condition variable on one > of the threads in the pool. > > The sequence of events is: > > main > ---------------------- > spawn threads > loop { > lock thread mutex > wait for packet > unlock mutex You keep the mutex locked while you wait? > send signal to thread Signal a condition or a kill() signal? > } > > threads > ---------------------- > loop { > wait for signal > do RADIUS crap > } > > The mutex in question is the same one as used by pthread_cond_wait. > > The problem is that I have to wake up the same thread /twice/ before > it answers a request (IOW, pthread_cond_signal is called twice before > the thread wakes up and `does RADIUS crap'). > > I haven't been able to reproduce this in something that isn't so > complicated (but I can give the full source to anyone who's interested), > but I was hoping someone might be able to tell me off-the-bat if it's > a known problem in some instances (or that it's a problem at all). I do this all the time. In fact I stopped working on such an application to answer your message. > > If not, I'll see what I can do to make the test simpler. Does the code build cleanly (gcc -Wall) on -current, without using a GNU configure script, and is it C code (not C++)? If yes, yes and yes, I'll look at it. -- John Birrell - jb@cimlogic.com.au; jb@freebsd.org http://www.cimlogic.com.au/ CIMlogic Pty Ltd, GPO Box 117A, Melbourne Vic 3001, Australia +61 418 353 137 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message