From owner-freebsd-current Fri Apr 11 10:11:04 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id KAA03662 for current-outgoing; Fri, 11 Apr 1997 10:11:04 -0700 (PDT) Received: from enst.enst.fr (2lb2W4AT5Ze4wdcumhofzatjZbHrQAiG@enst.enst.fr [137.194.2.16]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id KAA03644 for ; Fri, 11 Apr 1997 10:10:57 -0700 (PDT) Received: from email.enst.fr (email.enst.fr [137.194.168.17]) by enst.enst.fr (8.8.4/8.8.4) with ESMTP id TAA29480; Fri, 11 Apr 1997 19:10:21 +0200 (MET DST) Received: from nikopol.enst.fr (nikopol.enst.fr [137.194.168.105]) by email.enst.fr (8.8.4/8.8.4) with ESMTP id TAA07479; Fri, 11 Apr 1997 19:10:07 +0200 (MET DST) Received: (from fenyo@localhost) by nikopol.enst.fr (8.8.4/8.8.4) id TAA20766; Fri, 11 Apr 1997 19:10:03 +0200 (MET DST) Date: Fri, 11 Apr 1997 19:10:03 +0200 (MET DST) Message-Id: <199704111710.TAA20766@nikopol.enst.fr> From: "Alex Fenyo (eowyn)" To: current@FreeBSD.ORG Subject: Bug in libc_r implementation of pthread_cond_wait Cc: jb@cimlogic.com.au X-WWW: http://home.eowyn.fr.eu.org/~fenyo/documents/axel.html X-PGP-Key: finger alex@eowyn.fr.eu.org X-NIC-Handle: AF713 X-Whois: whois -h whois.internic.net fenyo X-Pager: 06-04-30-75-94 (for emergency only) Organization: Ecole Nationale Superieure des Telecommunications de Paris Reply-to: fenyo@email.enst.fr Sender: owner-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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