From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 31 00:44:50 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 7E4CE16A41F for ; Wed, 31 Aug 2005 00:44:50 +0000 (GMT) (envelope-from keramida@linux.gr) Received: from nic.ach.sch.gr (nic.sch.gr [194.63.238.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 687A943D4C for ; Wed, 31 Aug 2005 00:44:47 +0000 (GMT) (envelope-from keramida@linux.gr) Received: (qmail 8276 invoked by uid 207); 31 Aug 2005 00:44:45 -0000 Received: from keramida@linux.gr by nic by uid 201 with qmail-scanner-1.21 (sophie: 3.04/2.19/3.81. Clear:RC:1(81.186.70.81):. Processed in 0.537209 secs); 31 Aug 2005 00:44:46 -0000 Received: from dialup81.ach.sch.gr (HELO gothmog.gr) ([81.186.70.81]) (envelope-sender ) by nic.sch.gr (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 31 Aug 2005 00:44:44 -0000 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.4/8.13.4) with ESMTP id j7V0igKo020189; Wed, 31 Aug 2005 03:44:42 +0300 (EEST) (envelope-from keramida@linux.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.4/8.13.4/Submit) id j7V0ifLo020185; Wed, 31 Aug 2005 03:44:41 +0300 (EEST) (envelope-from keramida@linux.gr) Date: Wed, 31 Aug 2005 03:44:41 +0300 From: Giorgos Keramidas To: Daniel Valencia Message-ID: <20050831004441.GB17733@gothmog.gr> References: <20050831003539.4702.qmail@web53913.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050831003539.4702.qmail@web53913.mail.yahoo.com> Cc: freebsd-hackers@freebsd.org Subject: Re: strange behaviour with pthread_cond_wait() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 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 Aug 2005 00:44:50 -0000 On 2005-08-30 17:35, Daniel Valencia wrote: > Hello, everybody... > > I have this multithreaded program, and there are these two threads > that work together with a queue. The backend receive thread reads > packets and pushes them into the queue, while the frontend thread pops > them off the queue to hand them to the caller. This is an > implementation of a software switch. > > The issue is, i have this little piece of code in the thread which > actually performs the popping: This is not a complete, compilable program. It's usually much easier to track down problems by looking at a minimal example that exhibits the problem. Can you post one? > if( !_recvq.size() ) > { > int e = pthread_cond_wait( &_thread_cond_recv, > &_thread_mutex_recv ); > > if( e ) > { > std::perror( "pthread_cond_wait" ); > std::exit( e ); > } > } > > pthread_mutex_lock( &_recvq_mutex ); > p = _recvq.front(); > _recvq.pop(); > pthread_mutex_unlock( &_recvq_mutex );