Interrupts and Error Handling

Interrupts can be generated by hardware or software. Computers and operating systems vary in the types of interrupts that they support and the mechanisms by which they respond to them. In recent Microsoft Windows operating systems an interrupt management scheme hides these processing differences and the hardware abstraction layer (HAL) provides a virtual interrupt mechanism to the kernel.

The kernel’s trap handler is responsible for handling of all interrupts, exceptions (ie: errors), system service calls and virtual memory management. The major difference between interrupts and exceptions is that interrupts occur asynchronously (eg: when a hardware peripheral device needs some CPU time), whereas exceptions occur as a part of standard application execution (eg: when the result of a calculation is too large to be stored). Exceptions can usually be reproduced under test conditions, but interrupts involve timing relationships that are difficult to replicate.

Some interrupts have higher priority than others, eg: timer (system clock) interrupts are critical to many Windows functions, including pre-emptive multitasking, so they are allocated a higher priority than interrupts caused by peripheral devices such as printers and modems.

When an interrupt occurs, it is handled by an interrupt service routine (ISR), sometimes known as an error handler or exception handler. The kernel includes ISRs for many system interrupts such the system clock, power failure and process scheduling. Other ISRs are provided by the device drivers that manage peripheral hardware devices such as network adapters, keyboards and disk drives.

In some operating systems, further interrupts are blocked or masked while an interrupt is being processed. In recent Windows systems, low-priority interrupts are masked while a higher priority interrupt is being processed, but a high priority interrupt will take precedence over a lower priority interrupt.

Next: Applications Software