What is an interrupt? Explain the steps involved in handling or servicing an interrupt paying particular attention to the concept of priority. Give examples of interrupt types & number for standard PC architecture.
What is an interrupt? Explain the steps involved in handling or servicing
an interrupt paying particular attention to the concept of priority.
Give examples of interrupt types & number for standard PC architecture.
What is an interrupt?
An interrupt is a signal from a device attached to a computer or from a program within the computer that causes the main program that operates the computer (the operating system) to stop and figure out what to do next. Almost all personal (or larger) computers today are interrupt-driven - that is, they start down the list of computer instructions in one program (perhaps an application such as a word processor) and keep running the instructions until either (A) they can't go any further or (B) an interrupt signal is sensed. After the interrupt signal is sensed, the computer either resumes running the program it was running or begins running another program.
Basically, a single computer can perform only one computer instruction at a time. But, because it can be interrupted, it can take turns in which programs or sets of instructions that it performs. This is known as multitasking. It allows the user to do a number of different things at the same time. The computer simply takes turns managing the programs that the user effectively starts. Of course, the computer operates at speeds that make it seem as though all of the user's tasks are being performed at the same time. (The computer's operating system is good at using little pauses in operations and user think time to work on other programs.)
An operating system usually has some code that is called an interrupt handler. The interrupt handler prioritises the interrupts and saves them in a queue if more than one is waiting to be handled. The operating system has another little program, sometimes called a scheduler that figures out which program to give control to next.
In general, there are hardware interrupts and software interrupts. A hardware interrupt occurs, for example, when an I/O operation is completed such as reading some data into the computer from a tape drive. A software interrupt occurs when an application program terminates or requests certain services from the operating system. In a personal computer, a hardware interrupt request (IRQ) has a value associated with it that associates it with a particular device.
IRQ
An IRQ (interrupt request) value is an assigned location where the computer can expect a particular device to interrupt it when the device sends the computer signals about its operation. For example, when a printer has finished printing, it sends an interrupt signal to the computer.
The signal momentarily interrupts the computer so that it can decide what processing to do next. Since the computer might not understand multiple signals to the computer on the same interrupt line, a unique value must be specified for each device and its path to the computer.
Prior to Plug-and Play (PnP) devices, users often had to set IRQ values manually (or be aware of them) when adding a new device to a computer.
If you add a device that does not support PnP, the manufacturer will hopefully provide explicit directions on how to assign IRQ values for it since the average computer user does not have the technical knowledge to definer the IRQ values for a device themselves.
Why Interrupts Are Used to Process Information
The processor is a highly tuned machine that is designed to (basically) do one thing at a time. However, we use our computers in a way that requires the processor to at least appear to do many things at once. If you've ever used a multitasking operating system like Windows 95, you've done this; you may have been editing a document while downloading information on your modem and listening to a CD simultaneously. The processor is able to do this by sharing its time among the various programs it is running and the different devices that need its ...
This is a preview of the whole essay
The processor is a highly tuned machine that is designed to (basically) do one thing at a time. However, we use our computers in a way that requires the processor to at least appear to do many things at once. If you've ever used a multitasking operating system like Windows 95, you've done this; you may have been editing a document while downloading information on your modem and listening to a CD simultaneously. The processor is able to do this by sharing its time among the various programs it is running and the different devices that need its attention. It only appears that the processor is doing many things at once because of the amazingly high speed that it is able to switch between tasks.
Most of the different parts of the PC need to send information to and from the processor, and they expect to be able to get the processor's attention when they need to do this. The processor has to balance the information transfers it gets from various parts of the machine and make sure they are handled in an organised fashion. There are two basic ways that the processor could do this:
* Polling: The processor could take turns going to each device and asking if they have anything they need it to do. This is called polling the devices. In some situations in the computer world this technique is used, however it is not used by the processor in a PC for a couple of basic reasons. One reason is that it is wasteful; going around to all the devices constantly asking if they need the attention of the CPU wastes cycles that the processor could be doing something useful. This is particularly true because in most cases the answer will be "no". Another reason is that different devices need the processor's attention at differing rates; the mouse needs attention far less frequently than the hard disk, for example.
* Interrupting: The other way that the processor can handle information transfers is to let the devices request them when they need its attention. This is the basis for the use of interrupts. When a device has data to transfer, it generates an interrupt that says, "Attention required now, please". The processor then stops what it is doing and deals with the device that requested its attention. It actually can handle many such requests at a time, using a priority level for each to decide which to handle first.
In addition to the well-known hardware interrupts that we discuss in this section, there are also software interrupts. These are used by various software programs in response to different events that occur as the operating system and applications run. Basically, these represent the processor interrupting itself! This is part of how the processor is able to do many things at once. The other thing that software interrupts do is allow one program to access another one (usually an application or DOS accessing to the BIOS) without having to know where it resides in memory.
Interrupt Controllers
Device interrupts are fed to the processor using a special piece of hardware called an interrupt controller. The standard for this device is the Intel 8259 interrupt controller, and has been since early PCs. As with most of these dedicated controllers, in modern motherboards the 8259 are, in most cases, incorporated into a larger chip as part of the chipset.
The interrupt controller has 8 input lines that take requests from one of 8 different devices. The controller then passes the request on to the processor, telling it which device issued the request (which interrupt number triggered the request, from 0 to 7). The original PC and XT had one of these controllers, and hence supported interrupts 0 to 7 only.
Starting with the IBM AT, a second interrupt controller was added to the system to expand it; this was part of the expansion of the ISA system bus from 8 to 16 bits. In order to ensure compatibility the designers of the AT didn't want to change the single interrupt line going to the processor. So what they did instead was to cascade the two interrupt controllers together.
The first interrupt controller still has 8 inputs and a single output going to the processor. The second one has the same design, but it takes 8 new inputs (doubling the number of interrupts) and its output feeds into input line 2 of the first controller. If any of the inputs on the second controller become active, the output from that controller triggers interrupt no. 2 on the first controller, which then signals the processor.
IRQ2's line is now being used to cascade the second controller, so the AT's designers changed the wiring on the motherboard to send any devices that used IRQ2 over to IRQ9 instead. What this means is that any older devices that used IRQ2 now use IRQ9, and if you set any device to use IRQ2 on an AT or later system, it is really using IRQ9.
Devices designed to use IRQ2 as a primary setting are rare in today's systems, since IRQ2 has been out of use for over 10 years. In most cases IRQ2 is just considered "unusable", while IRQ9 is a regular, usable interrupt line. However, some modems for example still offer the use of IRQ2 as a way to get around the fact that COM3 and COM4 share interrupts with COM1 and COM2 by default.
IRQ Lines and the System Bus
The devices that use interrupts trigger them by signalling over lines provided on the ISA system bus. Most of the interrupts are provided to the system bus for use by devices; however, some of them are only used internally by the system, and therefore they are not given wires on the system bus. These are interrupts 0, 1, 2, 8 and 13, and are never available to expansion cards (IRQ2 is wired to IRQ9 on the motherboard.
As explained in this section on the ISA bus, the original bus was only 8 bits wide and had a single connector for expansion cards). The bus was expanded to 16 bits and a second connector slot added next to the first one; you can see this if you look at your motherboard, since all modern PCs use 16-bit slots.
The addition of this extra connector coincided with the addition of the second interrupt controller, and the lines for these extra IRQs were placed on this second slot. This means that in order to access any of these IRQs--10, 11, 12, 14 and 15--the card must have both connectors. While almost no motherboards today have 8-bit-only bus slots, there are still many expansion cards that only use one ISA connector. The most common example is an internal modem. These cards can only use IRQs 3, 4, 5, 6 and 7 (and 6 is almost always not available since the floppy disk controller uses it). They can also use IRQ 9 indirectly if they have the ability to use IRQ2, since 9 is wired to where 2 used to be.
Interrupt Priority
The PC processes device interrupts according to their priority level. This is a function of which interrupt line they use to enter the interrupt controller. For this reason, the priority levels are directly tied to the interrupt number:
* On an old PC, the priority of the interrupts is 0, 1, 2, 3, 4, 5, 6, and 7.
* On a modern machine, it's slightly more complicated.
Recall that the second set of eight interrupts is piped through the IRQ2 channel on the first interrupt controller. This means that the first controller views any of these interrupts as being at the priority level of its "IRQ2". The result of this is that the priorities become 0, 1, (8, 9, 10, 11, 12, 13, 14, 15), 3, 4, 5, 6, and 7. IRQs 8 to 15 take the place of IRQ2.
Non-Maskable Interrupts (NMI)
All of the regular interrupts that are normally used and referred to by number are called maskable interrupts. The processor is able to mask, or temporarily ignore; any interrupt if it needs to, so it can finish something else that it is doing. In addition, however, the PC has a non-maskable interrupt (NMI) that can be used for serious conditions that demand the processor's immediate attention. The NMI cannot be ignored by the system unless it is shut off specifically.
When a NMI signal is received, the processor immediately drops whatever it was doing and attends to it. As you can imagine, this could cause havoc if used improperly. In fact, the NMI signal is normally used only for critical problem situations, such as serious hardware errors. The most common use of NMI is to signal a parity error from the memory subsystem. This error must be dealt with immediately to prevent possible data corruption.
Interrupts, Multiple Devices and Conflicts
In general, interrupts are single-device resources. Because of the way the system bus is designed, it is not feasible for more than one device to use an interrupt at one time, because this can confuse the processor and cause it to respond to the wrong device at the wrong time. If two devices are attempteded to be used with the same IRQ, an IRQ conflict will result. This is an example of a resource conflict.
It is possible to share an IRQ among more than one device, but only under limited conditions. In essence, if you have two devices that you seldom use, and that you never use simultaneously, you may be able to have them share an IRQ. However, this is not the preferred method since it is much more prone to problems than just giving each device its own interrupt line.
One of the most common problems regarding shared IRQs is the use of the third and fourth serial (COM) ports, COM3 and COM4. By default, COM3 uses the same interrupt as COM1 (IRQ4), and COM4 uses the same interrupt as COM2 (IRQ3). It is possible to share COM ports on the same interrupt, but its important to be very careful not to use both devices at once.
Many modems will let you change the IRQ they use to IRQ5 or IRQ2, for example, to avoid this problem. Other common areas where interrupt conflicts occur are IRQ5, IRQ7 and IRQ12.
IRQ Details *
Here is a list of each of the 16 interrupt lines and provides a full description of what they are, how they are normally used, and any special information that is relevant to them. The general format for each section is as follows:
* IRQ Number: The number of the IRQ from 0 to 15.
* 16-Bit Priority: The priority level of the interrupt. 1 is the highest and 15 is the lowest.
* Bus Line: Indicates whether or not this IRQ is available to expansion devices on the system bus. This will say "8/16 bit" for an interrupt line available to all expansion devices, "16 bit only" for a line available only to 16-bit cards, or "No" for an interrupt used only by system devices.
* Typical Default Use: Description of the device or function that normally uses this IRQ in a regular modern PC.
* Other Common Uses: This is a list of other devices that commonly either use this IRQ or offer the use of this IRQ as one of their options. This list isn't exhaustive because there are a lot of oddball cards out there that may use unusual IRQs.
* Description: A description of the interrupt and how it is used, along with any relevant or interesting points about it or its history.
* Conflicts: A discussion of the likelihood of conflicts with this IRQ and what are the likely causes.
Automatic Resource Allocation
There are several settings in the PCI / PnP Configuration sections of the BIOS program that deal with assigning interrupt resources. This includes both regular IRQs and the internal PCI interrupt resources. For most applications there is no need to manually select or deal with these resources; in this case the default setting of automatic allocation should be selected, to enable automatic resource allocation.
IRQ Uses:
This table shows the typical uses of IRQ's and the priorities and it provides a reference, showing the 16 typical IRQ levels present in a typical PC.
IRQ
Bus Line?
Priority
Typical Default Use
Other Common Uses
0
no
System timer
None
no
2
Keyboard controller
None
2
no (rerouted)
n/a
None; cascade for IRQs 8-15. Replaced by IRQ 9
Modems, very old (EGA) video cards, COM3 (third serial port), COM4 (fourth serial port)
3
8/16-bit
1
COM2 (second serial port)
COM4 (fourth serial port), modems, sound cards, network cards, tape accelerator cards
4
8/16-bit
2
COM1 (first serial port)
COM3 (third serial port), modems, sound cards, network cards, tape accelerator cards
5
8/16-bit
3
Sound card
LPT2 (second parallel port), LPT3 (third parallel port), COM3 (third serial port), COM4 (fourth serial port), modems, network cards, tape accelerator cards, hard disk controller on old PC/XT
6
8/16-bit
4
Floppy disk controller
Tape accelerator cards
7
8/16-bit
5
LPT1 (first parallel port)
LPT2 (second parallel port), COM3 (third serial port), COM4 (fourth serial port), modems, sound cards, network cards, tape accelerator cards
8
no
3
Real-time clock
None
9
6-bit only
4
Network cards, sound cards, SCSI host adapters, PCI devices, rerouted IRQ2 devices
0
6-bit only
5
Network cards, sound cards, SCSI host adapters, secondary IDE channel, quaternary IDE channel, PCI devices
1
6-bit only
6
Network cards, sound cards, SCSI host adapters, VGA video cards, tertiary IDE channel, quaternary IDE channel, PCI devices
2
6-bit only
7
PS/2 mouse
Network cards, sound cards, SCSI host adapters, VGA video cards, tertiary IDE channel, PCI devices
3
no
8
Floating Point Unit (FPU / NPU / Math Coprocessor)
None
4
6-bit only
9
Primary IDE channel
SCSI host adapters
5
6-bit only
0
Secondary IDE channel
Network cards, SCSI host adapters
2.05