Date: Wed, 31 Aug 2005 03:44:41 +0300 From: Giorgos Keramidas <keramida@linux.gr> To: Daniel Valencia <fetrovsky@yahoo.com> Cc: freebsd-hackers@freebsd.org Subject: Re: strange behaviour with pthread_cond_wait() Message-ID: <20050831004441.GB17733@gothmog.gr> In-Reply-To: <20050831003539.4702.qmail@web53913.mail.yahoo.com> References: <20050831003539.4702.qmail@web53913.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-08-30 17:35, Daniel Valencia <fetrovsky@yahoo.com> 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 );
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050831004441.GB17733>
