This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Thread.interrupt() and pthread_cond_timedwait()
- To: java-discuss at sourceware dot cygnus dot com
- Subject: Thread.interrupt() and pthread_cond_timedwait()
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Wed, 08 Mar 2000 19:37:54 +1300
Recently I came across a nasty bug in our _Jv_Condwait implementation
when running on glibc 2.1.2. I didn't manage to isolate the exact
conditions that caused it, but in some cases pthread_cond_timedwait was
not waking up correctly on pthread_cond_broadcast, which translates to
wait() occasionally not waking up correctly to notifyAll(). This wasn't
showing up in any of our (or kaffe's) regression tests but was frequent
in one of my projects. Anyway, this was due to a bug in glibc and has
been fixed in the glibc 2.1.3 release:
http://sourceware.cygnus.com/cgi-bin/cvsweb.cgi/libc/linuxthreads/condvar.c?cvsroot=glibc
Unfortunatly, 2.1.3 has also changed the behavior of
pthread_cond_timedwait: signals no longer interrupt it. Apparantly some
people considered this a bug! ;-)
So, given both the bug in 2.1.2 and the change in 2.1.3, I propose to
revert part of this patch:
http://sourceware.cygnus.com/ml/java-patches/1999-q4/msg00107.html
which changed _Jv_CondWait to allways use pthread_cond_timedwait() on
linuxthreads. This means that interrupt() will no longer work on a
thread in wait() [it doesnt work on other platforms anyway].
pthread_cond_wait is lighter and faster anyway so its probibly for the
best.
We will have to come up with a proper way of implementing interrupt().
Someday I might write a beos-threads.cc just to show how easy it should
be :-)
regards
[ bryce ]