When using multitasking operating systems (like Windows, Mac OS X, and Linux etc.) users tend to have multiple programs, utilities and applications running concurrently/simultaneously. For example: editing a word document, downloading from the Internet and listening to music. In order to be able to do this the CPU shares its processing time among the tasks requiring its attention. These include user initiated tasks, the operating system, programs, utilities, memory management and quite a few “background” services and routines.
Communicating with the CPU
The majority of the subsystems in a PC need to send information to and receive information from the CPU and system memory (RAM). Most also expect to be able to get the CPU’s attention when they do so.
In order to improve a computer’s overall efficiency the CPU needs to balance the data transfers between itself and the various other subsystems of the machine as well as juggling various subsystems that may require “out of order” processing demands such as input/output (I/O) devices and human interface devices.
It must also take into account the fact that different subsystems will require differing levels of CPU support and processing time in order to satisfy their functional requirements. The mouse; for example, needs far less attention than a hard disk involved in the transference of a large multi-gigabyte file. There are basically 2 ways in which this can be done: CPU polling and device initiated interrupting.
Polling is the process whereby the CPU systematically locates and asks each device in turn if it requires any help or CPU processing time. Overall; polling is a very inefficient process, wasteful of a CPU’s finite resources because it requires the CPU to continually perform the same tasks (asking each device if it needs the CPU’s attention) over and over again. More often than not the device will not require the CPU’s attention.
Statistically; the most likely answer or result of a hardware polling query is that which it received last time (offer declined). To overcome polling’s inefficiency a different strategy; known as “Interrupting”; also referred to as Interrupt Request (IRQ), was developed.
The other way that the CPU (processor) can employ to handle CPU required processes and data transfers is to have the devices requiring the CPU’s attention to issue a request for attention as and when they require it. This is the basic concept of interrupt requests.
Thus when a device has data to transfer, it generates an interrupt that says “Mr. CPU I need your attention now, please”. The processor then stops what it is doing and deals with the device that requested its attention. Because modern CPUs are so fast in comparison with most other subsystems of a computer the modern CPU can handle many such interrupt requests at a time.
Suppose a typist is typing at a rate of 120 words per minute and that on average there are five letters per word. This equates to the typist producing 600 characters of keyboard input per minute. This means that an old 200 MHz Pentium class CPU will process 20,000,000 instructions between each keystroke.
This is why having the processor spend a lot of time asking the keyboard if it needs any help would be wasteful, especially since the typist may at any time stop for a minute or two to review the copy, or do something else like make a cup of coffee. Even while handling a full-bandwidth transfer from a 28,800 Kb/sec modem, which of course moves data much faster than the typist’s fingers, the processor has over 60,000 instruction cycles between the bytes it needs to process.
Interrupt Request Management
In the event of multiple simultaneous interrupt requests the CPU uses a priority system that gives a priority status to interrupt requests based upon the priority associated with the device issuing the request. This is known as Interrupt Request Management.
Hardware interrupts such as those mentioned above (typing/keyboard input and modem transfers) are distinguishable from software interrupts by the fact that they generally originate from a device outside the CPU.
Another type of interrupt that occurs in modern PCs; known as software interrupts, are generated by the operating system, programs and various other software applications. They are used by various software programs in response to different events that occur as the operating system and applications run. In essence a software interrupt represents the CPU interrupting itself (as the interrupt originates from within the CPU) and is part of the reason of how the CPU is able to do many things at once.
A computer’s BIOS provides various software routines (subprograms) that can be called by higher-level software such as DOS, Windows, or their applications, to perform different tasks. This includes actions like reading and writing from the hard disk, processing information received from devices, etc.
Another performance enhancing functionality that software interrupts make possible is facilitating system software (DOS or the operating system), applications and other software to directly access one another via BIOS routines without having to know where the target application resides in memory.
Interrupt Vector Table
Normally, to call a software routine you need to know its address (location) in memory. However; with interrupt requests a table called an interrupt vector table is created and this is used to bypass the need to explicitly know the correct address in memory. Now every time the system is booted, the BIOS puts addresses representing where its routines are located for each interrupt that it is configured to respond to.
Whenever DOS, the operating system or other applications want to use a BIOS routine, it generates a software interrupt. The system processes the interrupt by looking up the value in the interrupt vector table and then automatically jumps directly to the appropriate BIOS routine. Modern operating systems and applications as well as DOS can also directly use this interrupt vector table.
BIOS Assigned Logical Names
The BIOS assigns logical names to devices based on their IRQ number and memory address. For example: IRQ 3 and I/O address 2F8-2FFh becomes Com2.
For older systems; such as those based around the ISA bus, it is often the case that the default IRQ assignments must be preserved. This necessity is most common with older software and games that require the ISA SoundBlaster sound card to be accessible using the following configurations: IRQ 5, I/O Address 220h and DMA 1. Failure to comply will result in; at best no in game sound and at worst no game at all.
In short; interrupt requests are a mechanism that allows the various devices and software that make up a computer to jump the processing queue in order to have tasks of a predetermined “higher” priority to be executed “out of turn”. BIOS services are accessed using software interrupts, which are similar to the hardware interrupts except that they are generated inside the CPU by programs instead of being generated outside the CPU by hardware devices.