On Sun, 4 Feb 2001, Paul D. Schmidt wrote:
> Are there currently any known bugs with pthread_mutex_init
> and pthread_cond_init returning 0, but pthread_cond_wait
> returning EINVAL nonetheless?

Yes, it's a known bug with the _application_ ;-)

pthread_cond_[timed]wait must be called with a mutex and that
must be the only mutex used with that condition variable.  For
instance:

        pthread_mutex_t m1, m2;
        pthread_cond_t  cv;

        thread 1:
                pthread_mutex_lock(&m1);
                ret = pthread_cond_wait(&cv, &m1);
                pthread_mutex_unlock(&m1);

        thread 2:
                pthread_mutex_lock(&m2);
                ret = pthread_cond_wait(&cv, &m2);
                pthread_mutex_unlock(&m2);

can result in one of the threads returning EINVAL from
pthread_cond_wait if one thread is already waiting on the
condition variable when the other thread calls pthread_cond_wait().
There is no problem if only one thread is waiting on the
condition variable at any one time, but that still should
be avoided.

-- 
Dan Eischen


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to