second attempt to fix "idle to active" fast path

If another thread succeeds in entering the "exclusive" state while we
use the fast path to transition the current thread to "active", we
must switch back to "idle" temporarily to allow the exclusive thread a
chance to continue, and then retry the transition to "active" via the
slow path.
This commit is contained in:
Joel Dice 2009-11-28 15:35:15 -07:00
parent 3418a8bcbe
commit 1558b85acf

View File

@ -2422,12 +2422,13 @@ enter(Thread* t, Thread::State s)
// fast path
INCREMENT(&(t->m->activeCount), 1);
t->state = s;
if (t->m->exclusive) {
// a thread has entered exclusive mode - switch to slow path
assert(t, t->m->activeCount > 0);
INCREMENT(&(t->m->activeCount), -1);
// another thread has entered the exclusive state, so we
// return to idle and use the slow path to become active
enter(t, Thread::IdleState);
} else {
t->state = s;
break;
}
}