Thread.interrupt() and pthread_cond_timedwait()

Bryce McKinlay bryce@albatross.co.nz
Sat Apr 1 00:00:00 GMT 2000


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 ]


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /