Skip to content

Commit

Permalink
[scheduler] Fix waitUntilQueued() failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaomy3832 committed Nov 4, 2016
1 parent 3b5ae67 commit 51c4672
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 51c4672

Please sign in to comment.