* src/threads/thread.cpp (thread_set_state_*): Don't take the ThreadList
authorsr <none@none>
Wed, 15 Sep 2010 17:25:24 +0000 (19:25 +0200)
committersr <none@none>
Wed, 15 Sep 2010 17:25:24 +0000 (19:25 +0200)
commit642883f832867bf2fcb70aa702a68ba825c7118d
treee45e067670ffebe2bb8f60053fa09aeb86a4f8d0
parent67702ed5605e84f33724aeee9ccf5f82ea774084
* src/threads/thread.cpp (thread_set_state_*): Don't take the ThreadList
lock, most of the time.

We need the lock only when changing the state to terminated. This prevents
other threads from using a stale threadobject * (they have to take the lock,
of course). This changeset removes a nasty deadlock:

Thread 1 locks ThreadList::_mutex -> waitmutex (via thread_handle_interrupt
-> threads_thread_interrupt)
Thread 2 locks waitmutex -> ThreadList::_mutex (via
threads_wait_with_timeout -> thread_set_state_runnable)

The deadlock is provoked by running tests/threads/waitAndInterrupt.java (in
the CACAO source tree). The bug was introduced in changeset a62d7ef60606 (PR
120).
src/threads/thread.cpp