Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision e535eeb8ca65f325690f9d79d60ea2f3c9e9da35)
+++ kernel/generic/src/proc/scheduler.c	(revision 55821eead31822cd7053e1f55e528a9ba9197182)
@@ -187,5 +187,4 @@
 
 loop:
-	interrupts_enable();
 	
 	if (atomic_get(&CPU->nrdy) == 0) {
@@ -196,18 +195,19 @@
 		 */
 
-		/*
+		 /* Mark CPU as it was idle this clock tick */
+		 spinlock_lock(&CPU->lock);
+		 CPU->idle = true;
+		 spinlock_unlock(&CPU->lock);
+
+		 interrupts_enable();
+		 /*
 		 * An interrupt might occur right now and wake up a thread.
 		 * In such case, the CPU will continue to go to sleep
 		 * even though there is a runnable thread.
 		 */
-
-		 spinlock_lock(&CPU->lock);
-		 CPU->idle = true;
-		 spinlock_unlock(&CPU->lock);
 		 cpu_sleep();
+		 interrupts_disable();
 		 goto loop;
 	}
-
-	interrupts_disable();
 	
 	for (i = 0; i < RQ_COUNT; i++) {
