Date: Tue, 30 Aug 2005 17:35:39 -0700 (PDT) From: Daniel Valencia <fetrovsky@yahoo.com> To: freebsd-hackers@freebsd.org Subject: strange behaviour with pthread_cond_wait() Message-ID: <20050831003539.4702.qmail@web53913.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050831003539.4702.qmail>