Skip to content

Commit 51c4672

Browse files
committed
[scheduler] Fix waitUntilQueued() failure.
1 parent 3b5ae67 commit 51c4672

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/scheduler.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,16 @@ class Scheduler : public GlobAlloc, public Callee {
638638
if (futex_res == 0 || th->futexWord != 1) break;
639639
}
640640
//info("%d out of sched wait, got cid = %d, needsJoin = %d", th->gid, th->cid, th->needsJoin);
641+
// NOTE(mgao): After wakeup, waker assumes the wakee will wait on schedLock to join. See waitUntilQueued().
642+
// So we should get the lock regardless of needsJoin.
643+
futex_lock(&schedLock);
641644
if (th->needsJoin) {
642-
futex_lock(&schedLock);
643-
assert(th->needsJoin); //re-check after the lock
645+
//assert(th->needsJoin); //re-check after the lock
644646
zinfo->cores[th->cid]->join();
645647
bar.join(th->cid, &schedLock);
646648
//info("%d join done", th->gid);
647649
}
650+
futex_unlock(&schedLock);
648651
}
649652

650653
void wakeup(ThreadInfo* th, bool needsJoin) {

0 commit comments

Comments
 (0)