Timer used by operating systems that do preemptive multitasking
to interrupt running process
es, and return control
to the kernel1
, or the hardware device that provides this facility. The x86
system timer was initially a discrete chip, but is now built into the south bridge
. The system timer interrupts the processor on IRQ
0, at a rate that can be programmed by the processor
.It is possible to use the system timer as a millisecond-accurate timer, by programming it to interrupt faster than normal, and only passing the interrupt to the system at the normal rate2
1 - This is one of the few ways to return to protected mode once the processor is in virtual 86 mode (It also returns to the kernel's interrupt handlers upon an exception (divide by zero, segmentation fault, etc.) Or when the INT instruction calls the kernel.) The important thing is that you can't get into protected mode without calling the kernel.
If this were not the case, it would be possible for a user process to somehow get into protected mode, and from there it could write to other process's memory space, and execute privileged instructions. Without a system timer, it would not be possible to write an operating system with any real form of security.3
2 - It's possible to do this under windows 9x, because it is not an operating system with any real form of security.
3 - See also cooperative multitasking for how to bring down any operating system that depends on processes to yield