Patch: posix-threads code update
Bryce McKinlay
bryce@albatross.co.nz
Thu Mar 23 05:56:00 GMT 2000
This patch improves the posix-threads code. It should fix a lot of bugs,
improve portability, and reduce code complexity.
The major changes are:
1. We no longer (ever) use the platform-native implementation of
recursive mutexes. These are a non-standard extension to the
posix-threads spec, are buggy on some platforms when they do exist, and
do not interact well with pthread_cond_wait(). Instead, we now implement
recursion ourselves in the _Jv_MutexLock()/_Jv_MutexUnlock() calls.
2. We now use our own interruptable condition variables to implement
wait()/sleep()/join(). Each thread has its own associated 'native'
condition variable and mutex that is used to implement waiting. For each
libgcj condition variable, a linked list of threads waiting on that
variable is maintained. When a condition variable is notified, it picks
one waiting thread, signals it, and removes it from the linked list of
waiters (wait set). When a thread is interrupted (or if a wait timeout
occurs), the thread removes itself from the wait set for the condition
variable it is waiting on. This implementation is based on a suggestion
from Tom Tromey (thanks, Tom).
The patch also fixes a few other threads bugs, which should be
self-explanitory.
I'm awaiting review of this code. Enjoy!
regards
[ bryce ]
More information about the Java-patches
mailing list