projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update comments.
[pintos-anon]
/
src
/
devices
/
timer.c
diff --git
a/src/devices/timer.c
b/src/devices/timer.c
index 8f4838f048e04ec80d0060fc10cd1a3d77da3216..9c611a1d3eda68b6fd2317304faaef9381f9eb40 100644
(file)
--- a/
src/devices/timer.c
+++ b/
src/devices/timer.c
@@
-3,6
+3,7
@@
#include <round.h>
#include "threads/interrupt.h"
#include "threads/io.h"
#include <round.h>
#include "threads/interrupt.h"
#include "threads/io.h"
+#include "threads/thread.h"
#if TIMER_FREQ < 19
#error 8254 timer requires TIMER_FREQ >= 19
#if TIMER_FREQ < 19
#error 8254 timer requires TIMER_FREQ >= 19
@@
-20,7
+21,7
@@
static volatile int64_t ticks;
static intr_handler_func timer_interrupt;
static intr_handler_func timer_interrupt;
-/* Sets up the 8254 Programmable Inter
rupt
Timer (PIT) to
+/* Sets up the 8254 Programmable Inter
val
Timer (PIT) to
interrupt PIT_FREQ times per second, and registers the
corresponding interrupt. */
void
interrupt PIT_FREQ times per second, and registers the
corresponding interrupt. */
void
@@
-55,14
+56,15
@@
timer_elapsed (int64_t then)
return timer_ticks () - then;
}
return timer_ticks () - then;
}
-/* Suspends execution
s
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)
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. */
}
/* Returns MS milliseconds in timer ticks, rounding up. */