From 64f2ca225974f808be23f1e1450e4d490770cae7 Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Thu, 15 Jan 2015 21:24:15 -0800 Subject: [PATCH] Fix a bug in the scheduler --- sys/kern/thread.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/kern/thread.c b/sys/kern/thread.c index 8b70a25..47bc712 100644 --- a/sys/kern/thread.c +++ b/sys/kern/thread.c @@ -226,6 +226,14 @@ Thread_Scheduler() // Select next thread next = TAILQ_FIRST(&runnableQueue); + if (!next) { + /* + * There may be no other runnable processes on this core. This is a + * good opportunity to migrate threads. + */ + Spinlock_Unlock(&threadLock); + return; + } TAILQ_REMOVE(&runnableQueue, next, schedQueue); prev = curProc;