There are three main types of interrupts:
A taxonomy of Pentium interrupts is shown below:
Software InterruptsSoftware interrupts are initiated by executing the interrupt instruction INT in a program. Software interrupts are mainly used in accessing I/O devices such as the keyboard, printer, screen, disk drive, etc. For example, we use the INT 21H instruction to read a character or a string from the keyboard or display a character or a string on the screen.
Software interrupts can be classified into system-defined or user-defined. System-defined software interrupts are those whose interrupt service routines are supported by BIOS and DOS. User-defined interrupts are those whose interrupt service routines are provided by the user.
The format of the interrupt instruction is:
where interrupt-type is an integer in the range 0 through 255. Thus, there are 256 different interrupt types. This is a sufficiently large number, as each interrupt type can be parameterized to provide several services. For example, there are more than 80 different services (called functions) provided by DOS through INT 21H.
The following table shows which of the 256 interrupt types interrupts are BIOS interrupts, DOS interrupts, or user interrupts.
In addition to the INT instruction, there is only one additional conditional software interrupt instruction, INTO, interrupt on overflow, which invokes INT 4 when the overflow flag is set. Note that the interrupt instructions have no effect on the flags.
Hardware interrupts are generated by hardware devices to get the attention of the CPU. For example, when a key is pressed, the keyboard generates an interrupt causing the CPU to suspend its present activity and execute the keyboard interrupt service routine to process the key.
Hardware interrupts can be either maskable or non-maskable. Maskable interrupts are initiated through the CPU pin INTR while non-maskable interrupts are initiated through the CPU pin NMI. The non-maskable interrupts are serviced by the CPU immediately after completing the execution of the current instruction. However, maskable interrupts can be delayed until execution reaches a convenient point. One example of non-maskable interrupts is the RAM parity error indicating memory malfunction.
Interrupt Flag (IF)The Interrupt Flag (IF) controls whether maskable interrupts are delayed or not. When IF=1, the maskable interrupts will be serviced by the CPU. However, when IF=0 the maskable interrupts will be delayed until the IF becomes 1.
The instruction STI can be used to set the interrupt flag, while the instruction CLI can be used to clear the interrupt flag.
Identifying Hardware Interrupt TypesIn response to a hardware interrupt request on the INTR pin, the CPU initiates an interrupt acknowledge sequence. As part of this sequence, the CPU sends out an interrupt acknowledge (INTA) signal, and the interrupting device places the interrupt type number on the data bus.
Handling Interrupts from Several I/O DevicesMost hardware interrupts are maskable interrupts. Thus, all interrupts requested from external devices are initiated through the INTR pin. When more than one device interrupts, we have to have a mechanism to prioritize these interrupts and forward only one interrupt request at a time to the CPU while keeping the other interrupt requests pending for their turn. This mechanism can be implemented by using a special chip -- the Intel 8259 Programmable Interrupt Controller.
Processor Interrupts or ExceptionsExceptions are processor interrupts to handle instruction faults. An example of an exception is the divide error fault, which is generated when the quotient can not fit in the quotient register.
Exceptions are classified into three types depending on the way they are reported and whether or not the instruction that interrupted is restarted:
Faults and traps are reported at instructions boundaries. When a fault is reported, the system state is restored to the state before the instruction that caused the interrupt so that the instruction can be restarted. Examples of faults are the divide error fault and the segment-not-present fault. The segment-not-present fault is caused by a reference to data in a segment that is not in memory. Then, the exception handler must load the missing segment from the hard disk and resume program execution starting with the instruction that caused the exception.
On the other hand, when a trap is reported, the system state is restored to the state after the instruction that caused the interrupt. An example of a trap is the overflow exception (INT 4).
Aborts are exceptions that report severe errors. Examples include hardware errors and inconsistent values in system tables.