strange behaviour with pthread_cond_wait()

Giorgos Keramidas keramida at linux.gr
Wed Aug 31 00:44:50 GMT 2005


On 2005-08-30 17:35, Daniel Valencia <fetrovsky at 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 );


More information about the freebsd-hackers mailing list