From: Ben Pfaff Date: Sat, 11 Sep 2004 23:16:45 +0000 (+0000) Subject: Call thread_yield() in timer_sleep() if interrupts are on. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=208fb587faa75eaa0e740db9b605ff3d7ba24905;p=pintos-anon Call thread_yield() in timer_sleep() if interrupts are on. --- diff --git a/src/devices/timer.c b/src/devices/timer.c index 8f4838f..200d58f 100644 --- a/src/devices/timer.c +++ b/src/devices/timer.c @@ -3,6 +3,7 @@ #include #include "threads/interrupt.h" #include "threads/io.h" +#include "threads/thread.h" #if TIMER_FREQ < 19 #error 8254 timer requires TIMER_FREQ >= 19 @@ -55,14 +56,15 @@ timer_elapsed (int64_t then) return timer_ticks () - then; } -/* Suspends executions for approximately TICKS timer ticks. */ +/* Suspends execution for approximately TICKS timer ticks. */ void timer_sleep (int64_t ticks) { int64_t start = timer_ticks (); while (timer_elapsed (start) < ticks) - continue; + if (intr_get_level () == INTR_ON) + thread_yield (); } /* Returns MS milliseconds in timer ticks, rounding up. */