The time manager handles time intervals in the kernel. This driver does not provide real date and time calculation routines. It is rather used as a rate generator, to wake the kernel up at accurate intervals of time, mesured in ticks. In k we will use the 8254 PIT.
NAME gettick - get the time SYNOPSIS unsigned long gettick(void); DESCRIPTION gettick() returns the number of milliseconds elapsed since the machine started. RETURN VALUE gettick() returns the time in milliseconds.
Since we only need a periodic source of interrupt to implement the
syscall, we will use the Mode 2 of the 8254
on the Counter 0, with an interrupt rate of 100Hz. The interrupt handler will
just increment a global variable on each interrupt: the number of tick since
the machine started.
Possible bug causes
- Execution context may be corrupted. Check twice whether the context is correctly restored and wether the stack is well adjusted
- Hardware interrupts may have been disabled with CLI or may have not been enabled with STI
- The timer interrupt may be masked in the PIC