From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 31 00:48:20 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 572F816A41F for ; Wed, 31 Aug 2005 00:48:20 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF22343D45 for ; Wed, 31 Aug 2005 00:48:19 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.4/8.13.4/NETPLEX) with ESMTP id j7V0mIei004171; Tue, 30 Aug 2005 20:48:18 -0400 (EDT) Date: Tue, 30 Aug 2005 20:48:18 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Daniel Valencia In-Reply-To: <20050831003539.4702.qmail@web53913.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) 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 Reply-To: Daniel Eischen 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:48:20 -0000 On Tue, 30 Aug 2005, 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: [ ... ] > And when I runn my program, it will immediately exit. > The message is: > > pthread_cond_wait: Unknown error: 0 > > Not only that: the returned value (e) is 1, while > EINVAL is 22. According to the man pages, if 1 is EPERM. And from the POSIX Spec (see http://www.opengroup.org/onlinepubs/009695399/toc.htm): [EPERM] The mutex was not owned by the current thread at the time of the call. I suggest Butenhof's "Programming with POSIX Threads" book. -- DE