diff --git a/src/scheduler.h b/src/scheduler.h index 9abe6584..6ebf2bd5 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -638,13 +638,16 @@ class Scheduler : public GlobAlloc, public Callee { if (futex_res == 0 || th->futexWord != 1) break; } //info("%d out of sched wait, got cid = %d, needsJoin = %d", th->gid, th->cid, th->needsJoin); + // NOTE(mgao): After wakeup, waker assumes the wakee will wait on schedLock to join. See waitUntilQueued(). + // So we should get the lock regardless of needsJoin. + futex_lock(&schedLock); if (th->needsJoin) { - futex_lock(&schedLock); - assert(th->needsJoin); //re-check after the lock + //assert(th->needsJoin); //re-check after the lock zinfo->cores[th->cid]->join(); bar.join(th->cid, &schedLock); //info("%d join done", th->gid); } + futex_unlock(&schedLock); } void wakeup(ThreadInfo* th, bool needsJoin) {