Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Sep 1997 06:25:35 -0700 (PDT)
From:      thz@tuebingen.netsurf.de
To:        freebsd-gnats-submit@FreeBSD.ORG
Subject:   bin/4554: pthread_cond_wait() doesn't wait for pthread_cond_signal()
Message-ID:  <199709161325.GAA23560@hub.freebsd.org>
Resent-Message-ID: <199709161330.GAA23785@hub.freebsd.org>

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

>Number:         4554
>Category:       bin
>Synopsis:       pthread_cond_wait() doesn't wait for pthread_cond_signal()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 16 06:30:00 PDT 1997
>Last-Modified:
>Originator:     Thomas Zenker
>Organization:
Lennartz electronic
>Release:        2.2.1/2.2.2
>Environment:
>Description:
pthread_cond_wait returns immediately without
waiting for pthread_cond_signal by another thread.

the reason is that in pthread_cond_wait the wakeup_time.tv_sec
is not explicitely set to "wait forever" (-1).
Debugging shows: wakeup_time.tv_sec is allways implicitely 
set to "wakeup immediately" (0).

>How-To-Repeat:
Calling pthread_cond_wait() never stops the current thread.

>Fix:
Set wakeup_time.tv_sec explicitely to wait forever in the function
pthread_cond_wait() in file "uthread_cond.c".

*** /vol/cdrom/usr/src/lib/libc_r/uthread/uthread_cond.c        Fri Sep 20 08:3:50 1996
--- ./uthread_cond.c    Tue Sep 16 12:54:56 1997
***************
*** 149,154 ****
--- 149,158 ----
                switch ((*cond)->c_type) {
                        /* Fast condition variable: */
                case COND_TYPE_FAST:
+                       /* Set the wakeup time: wait forever */
+                       _thread_run->wakeup_time.tv_sec = -1;
+                       _thread_run->wakeup_time.tv_nsec = -1;
+ 
                        /* Queue the running thread for the condition variable:*/
                                _thread_queue_enq(&(*cond)->c_queue, _thread_run
);
  

>Audit-Trail:
>Unformatted:



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