#include "devices/timer.h"
#include <debug.h>
+#include <inttypes.h>
#include <round.h>
+#include <stdio.h>
#include "threads/interrupt.h"
#include "threads/io.h"
#include "threads/thread.h"
+/* See [8254] for hardware details of the 8254 timer chip. */
+
#if TIMER_FREQ < 19
#error 8254 timer requires TIMER_FREQ >= 19
#endif
static intr_handler_func timer_interrupt;
-/* Sets up the 8254 Programmable Interrupt Timer (PIT) to
+/* Sets up the 8254 Programmable Interval Timer (PIT) to
interrupt PIT_FREQ times per second, and registers the
corresponding interrupt. */
void
{
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++;
+ thread_tick ();
if (ticks % TIME_SLICE == 0)
intr_yield_on_return ();
}