strange behaviour with pthread_cond_wait()

Daniel Eischen deischen at freebsd.org
Wed Aug 31 00:48:20 GMT 2005


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



More information about the freebsd-hackers mailing list