Before starting to wait the undertaker does now check whether there's
already a dead thread available. Fixes a race condition. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25754 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e72e5275ff
commit
0cb2617fa5
@ -540,21 +540,21 @@ undertaker(void* /*args*/)
|
||||
{
|
||||
while (true) {
|
||||
// wait for a thread to bury
|
||||
ConditionVariableEntry conditionEntry;
|
||||
|
||||
InterruptsSpinLocker locker(thread_spinlock);
|
||||
sUndertakerCondition.Add(&conditionEntry);
|
||||
locker.Unlock();
|
||||
|
||||
conditionEntry.Wait();
|
||||
while (sUndertakerEntries.IsEmpty()) {
|
||||
ConditionVariableEntry conditionEntry;
|
||||
sUndertakerCondition.Add(&conditionEntry);
|
||||
locker.Unlock();
|
||||
|
||||
conditionEntry.Wait();
|
||||
|
||||
locker.Lock();
|
||||
}
|
||||
|
||||
locker.Lock();
|
||||
UndertakerEntry* _entry = sUndertakerEntries.RemoveHead();
|
||||
locker.Unlock();
|
||||
|
||||
if (_entry == NULL)
|
||||
continue;
|
||||
|
||||
UndertakerEntry entry = *_entry;
|
||||
// we need a copy, since the original entry is on the thread's stack
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user