From 51c467230b0c06cb21d7fa3ba77aeb93842b125f Mon Sep 17 00:00:00 2001 From: Mingyu Gao Date: Fri, 4 Nov 2016 09:36:28 -0700 Subject: [PATCH] [scheduler] Fix waitUntilQueued() failure. --- src/scheduler.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) {