projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Print statistics at power off.
[pintos-anon]
/
src
/
devices
/
timer.c
diff --git
a/src/devices/timer.c
b/src/devices/timer.c
index 9c611a1d3eda68b6fd2317304faaef9381f9eb40..8f47c810ffc8af5a1c6804933fad710929450318 100644
(file)
--- a/
src/devices/timer.c
+++ b/
src/devices/timer.c
@@
-1,6
+1,8
@@
#include "devices/timer.h"
#include <debug.h>
#include "devices/timer.h"
#include <debug.h>
+#include <inttypes.h>
#include <round.h>
#include <round.h>
+#include <stdio.h>
#include "threads/interrupt.h"
#include "threads/io.h"
#include "threads/thread.h"
#include "threads/interrupt.h"
#include "threads/io.h"
#include "threads/thread.h"
@@
-91,12
+93,20
@@
timer_ns2ticks (int64_t ns)
{
return DIV_ROUND_UP (ns * TIMER_FREQ, 1000000000);
}
{
return DIV_ROUND_UP (ns * TIMER_FREQ, 1000000000);
}
+
+/* Prints timer statistics. */
+void
+timer_print_stats (void)
+{
+ printf ("Timer: %"PRId64" ticks.\n", ticks);
+}
\f
/* Timer interrupt handler. */
static void
timer_interrupt (struct intr_frame *args UNUSED)
{
ticks++;
\f
/* Timer interrupt handler. */
static void
timer_interrupt (struct intr_frame *args UNUSED)
{
ticks++;
+ thread_tick ();
if (ticks % TIME_SLICE == 0)
intr_yield_on_return ();
}
if (ticks % TIME_SLICE == 0)
intr_yield_on_return ();
}