Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Apr 1997 19:10:03 +0200 (MET DST)
From:      "Alex Fenyo (eowyn)" <fenyo@email.enst.fr>
To:        current@FreeBSD.ORG
Cc:        jb@cimlogic.com.au
Subject:   Bug in libc_r implementation of pthread_cond_wait
Message-ID:  <199704111710.TAA20766@nikopol.enst.fr>

next in thread | raw e-mail | index | archive | help

I encountered a problem using pthread_cond_wait() that seems to be
broken : the thread that calls pthread_cond_wait() is always
rescheduled (even if there is no call to pthread_cond_signal() or
other reason to be rescheduled).

This is due to the fact that _thread_kern_sched()
(src/lib/libc_r/uthread/uthread_kern.c)
tests pthread->wakeup_time.tv_sec for the value -1 to know
if the waiting thread is to timeout or wait forever.
But pthread_cond_wait() doesn't set this value.

Can somebody change this code (pthread_cond_wait() in
src/lib/libc_r/uthread/uthread_cond.c) :

------------------------------------------------------------
/* Process according to condition variable type: */
   switch ((*cond)->c_type) {
   /* Fast condition variable: */
   case COND_TYPE_FAST:
   /* Queue the running thread for the condition variable: */
    _thread_queue_enq(&(*cond)->c_queue, _thread_run
);
------------------------------------------------------------

by this one :

------------------------------------------------------------
/* Process according to condition variable type: */
   switch ((*cond)->c_type) {
   /* Fast condition variable: */
   case COND_TYPE_FAST:
    _thread_run->wakeup_time.tv_sec = -1;
   /* Queue the running thread for the condition variable: */
    _thread_queue_enq(&(*cond)->c_queue, _thread_run
);
------------------------------------------------------------

Alexandre Fenyo



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704111710.TAA20766>