The Timer interrupt handler doesn't have to do much: the Periodic Interval Timer chip doesn't need any steps to acknowledge the interrupt it generated. That means that the handler just has to:
- Save the registers it's going to use;
- Acknowledge the interrupt in the PIC;
CALLthe generic Task Switching code;
- Restore the registers;
- Return to the interrupted code.
Note that if a Task Switch occurred, the code that was resumed in the last step won't be the actual code that was interrupted: that code has been paused until the Task Scheduler gets back around to it.
; ; Ints/Timer.inc ; ; This module implements the Timer interrupt handler. ; It simply performs some housekeeping and then calls the generic Task ; Switching code. Ints.Timer: PUSH EAX ; Need this register MOV AL,Dev.PIC.Cmd.EOI ; Acknowledge interrupt in PIC OUT Dev.PIC.A.Cmd,AL ; (Note interrupts still off) CALL Ints.Switch ; Switch Task POP EAX IRETD ; And return where we left off