fix race condition introduced in previous commit

This commit is contained in:
Joel Dice 2009-11-28 15:24:02 -07:00
parent 75934c8342
commit 3418a8bcbe

View File

@ -2421,10 +2421,18 @@ enter(Thread* t, Thread::State s)
if (t->state == Thread::IdleState and t->m->exclusive == 0) { if (t->state == Thread::IdleState and t->m->exclusive == 0) {
// fast path // fast path
INCREMENT(&(t->m->activeCount), 1); INCREMENT(&(t->m->activeCount), 1);
t->state = s;
break; if (t->m->exclusive) {
} else { // a thread has entered exclusive mode - switch to slow path
ACQUIRE_LOCK; assert(t, t->m->activeCount > 0);
INCREMENT(&(t->m->activeCount), -1);
} else {
t->state = s;
break;
}
}
{ ACQUIRE_LOCK;
switch (t->state) { switch (t->state) {
case Thread::ExclusiveState: { case Thread::ExclusiveState: {