This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Re: Patch: Posix thread sleep timeout fix
- To: Matt Welsh <mdw@cs.berkeley.edu>
- Subject: Re: Patch: Posix thread sleep timeout fix
- From: Tom Tromey <tromey@cygnus.com>
- Date: Tue, 7 Sep 1999 13:06:28 -0700
- Cc: java-patches@sourceware.cygnus.com, tromey@cygnus.com
- References: <199909071952.MAA31265@bhikku.CS.Berkeley.EDU>
>>>>> "Matt" == Matt Welsh <mdw@cs.berkeley.edu> writes:
Matt> The following patch fixes the problem where threads doing a
Matt> sleep() operation would be prematurely woken up by the GC signal
Matt> handlers.
Thanks. There are a few changes we need before I can check this in.
Matt> 1999-09-07 Matt Welsh <mdw@cs.berkeley.edu>
Matt> * libjava/posix-threads.cc: Added _Jv_ThreadDataKey to map
Matt> from POSIX thread back to the _Jv_Thread_t*
Matt> * Added FLAG_INTERRUPTED; this is set when the thread is
Matt> interrupted by another Java thread.
Matt> * _Jv_CondWait() continues to sleep if interrupted by the GC
Matt> * libjava/include/posix-threads.h: Added _Jv_CurrentThreadData()
Please write ChangeLog entries according to the GNU Coding Standards.
Matt> ! if (millis == 0 && nanos == 0) {
Matt> r = pthread_cond_wait (cv, pmu);
Matt> + }
Please follow our indentation style. This is rougly the GNU C style,
with extensions for C++ and Java.
Matt> ! resleep:
I'd prefer a while loop instead of a goto. In libgcj we've pretty
much restricted the use of goto to abnormal terminations (well, there
might be exceptions in the interpreter and the FP code, but those are
special cases).
Matt> ! (void)pthread_cond_wait (&mu->cond, &mu->mutex);
Don't cast to void.
The basic idea behind the patch looks good to me. If you make these
changes, I'll check it in. I know this is pedantic, and that other
code in libgcj doesn't follow the guidelines, but I'd rather we were
consistent. Letting non-conforming code in in the past was a mistake.
Thanks!
Tom