If the thread termination invokes user code after th->status becomes THREAD_KILLED, and the user unblock function causes that th->status to become something else (e.g. THREAD_RUNNING), threads waiting in thread_join_sleep will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as th->value becomes defined.
This reverts commit 6505c77501f1924571b2fe620c5c7b31ede0cd22.
Fix potential hang when joining threads.
If the thread termination invokes user code after
th->statusbecomesTHREAD_KILLED, and the user unblock function causes thatth->statustobecome something else (e.g.
THREAD_RUNNING), threads waiting inthread_join_sleepwill hang forever. We move the unblock function callto before the thread status is updated, and allow threads to join as soon
as
th->valuebecomes defined.This reverts commit 6505c77501f1924571b2fe620c5c7b31ede0cd22.