From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 31 00:35:40 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 31DF916A41F for ; Wed, 31 Aug 2005 00:35:40 +0000 (GMT) (envelope-from fetrovsky@yahoo.com) Received: from web53913.mail.yahoo.com (web53913.mail.yahoo.com [206.190.38.162]) by mx1.FreeBSD.org (Postfix) with SMTP id A7DDB43D46 for ; Wed, 31 Aug 2005 00:35:39 +0000 (GMT) (envelope-from fetrovsky@yahoo.com) Received: (qmail 4704 invoked by uid 60001); 31 Aug 2005 00:35:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=LWML1QWmU0K8+pX8aonXohdJ8pifgxqFhFbIM8Q8eImTfgRWb9yrFJTq2KyUQoJLq7e+BfEoaMJA9yLELLYssuZIGneIzwwlpen7Ywu395B5ErkYm4oFHJOMH66L5A8o75gUieQodfimvdbGWBuHCODPkEn3jKOFuiGd/ysbC1I= ; Message-ID: <20050831003539.4702.qmail@web53913.mail.yahoo.com> Received: from [128.200.38.50] by web53913.mail.yahoo.com via HTTP; Tue, 30 Aug 2005 17:35:39 PDT Date: Tue, 30 Aug 2005 17:35:39 -0700 (PDT) From: Daniel Valencia To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: 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:35:40 -0000 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: 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 ); 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 successful, pthread_cond_wait() will return 0; else, it will return a value indicating the error (the only possible value being EINVAL). My mutex address is not NULL, for I am taking the address of an automatic object (I checked anyways). Any hints will be greatly appreciated. Thank you, Daniel __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com