mirror of
https://github.com/SmallPond/MIT6.828_OS.git
synced 2026-02-03 11:03:16 +08:00
27 lines
359 B
C
27 lines
359 B
C
#include <kern/time.h>
|
|
#include <inc/assert.h>
|
|
|
|
static unsigned int ticks;
|
|
|
|
void
|
|
time_init(void)
|
|
{
|
|
ticks = 0;
|
|
}
|
|
|
|
// This should be called once per timer interrupt. A timer interrupt
|
|
// fires every 10 ms.
|
|
void
|
|
time_tick(void)
|
|
{
|
|
ticks++;
|
|
if (ticks * 10 < ticks)
|
|
panic("time_tick: time overflowed");
|
|
}
|
|
|
|
unsigned int
|
|
time_msec(void)
|
|
{
|
|
return ticks * 10;
|
|
}
|