Interrupt Requests (irqs)

Posted: February 10, 2011 in Uncategorized

Interrupt Requesting (IRQ) is a computer system performance enhancing technology that plays a key role in how the CPU performs input/output processing and interfaces with every peripheral in the computer, from the keyboard and mouse to the hard disk and modem. It is through IRQ prioritization that the CPU juggles multiple concurrent tasks thereby giving the impression that it is doing many things at once.

A computer’s main processor (CPU) is a highly-tuned machine that is designed to (basically) do one thing at a time. For example; execute the current instruction or operation. However; because of the way in which we humans work and use computers, we require the CPU to do many things at once (or at least to seem to be doing many things simultaneously).

Multitasking – Projecting the impression that it (the CPU) is performing many tasks simultaneously is known as “multitasking”. Modern CPUs contain multiple processing pipelines and the newer CPUs of today actually have multiple processing cores each with its own full complement of multiple processingpipelines.

This latter development (multiple complete processing cores) has indeed given the CPU the capability to perform multiple tasks simultaneously and not merely just seem to be doing so. The way in which processing tasks are managed and distributed among the multiple processing pipelines of the multiple cores is however; still achieved in pretty much the same way that it has always been done.

Multitasking Operating System – 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 you may be: editing a word document, downloading from the Internet and listening to music.

In order to be able to do this the CPU will share its processing time among the tasks requiring its attention including user initiated tasks, the operating system, programs, utilities, memory management and quite a few “background” services and routines. It only appears that the processor is doing many things at once because of the incredible speeds that modern CPUs are able to switch between tasks.

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 also needs to balance the data transfers between itself and the various other subsystems of the machine. In addition; some of a computer’s subsystems such as input/output (I/O) devices and human interface devices, all tend to require “special” attention.

Different Requirements – Another influential factor here is that different devices require different amounts of CPU time at various different irregular intervals.

The mouse; for example, needs far less attention than a hard disk involved in the transference of a large multi-gigabyte file. Thus; in the interest of a more efficient use of a computer’s finite resources, it is most beneficial if the amount of CPU time assigned to each device reflects the type of device and the nature of the operation and processing tasks involved.

In the above example of the resource needs of the mouse versus those of the hard drive; more resources can be allocated (even dedicated) to the hard drive for the duration of its current operation(s) while the mouse gets a smaller amount of CPU time.

When the hard drive is finished its current task(s) it may not be required to perform any transactions for various irregular periods of time. The system will then reassign those resources that were being used by the hard drive to other devices and processes as and when required.

Managing Processes – The computer (via the CPU) must also ensure that all active (running) processes and tasks are managed in the most efficient organized manner possible. There are basically 2 ways in which this can be done: CPU polling and device initiated interrupting.

Polling – Polling is the process whereby the CPU systematically locates and asks each device in turn if it requires any help or CPU processing time. This strategy (polling) is a very inefficient process because it is a waste of finite resources.

With polling the CPU is required 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).

With polling the CPU will continue to ask each device in sequence the same question ad infinitum. To overcome polling’s inefficiency a different strategy; known as “Interrupting”; also referred to as Interrupt Request (IRQ), was developed.

Interrupting – 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. Modern CPUs can handle many such requests at a time. 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.

Supply and Demand – One way of looking at interrupt requests is from a supply and demand perspective. While; having the CPU interrupted all the time may at first glance appear to be an inefficient way to run a computer, when examined closer reality proves otherwise. A large part of the reason is that the modern CPU is literally light years ahead; in terms of speed, when compared to the vast majority of devices conducting transactions with it. To put it into perspective let us consider the following scenario:

Let us suppose that 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 you might stop for a minute or two to review the copy, or do something else like make a cup of coffee. In fact; 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.

Hardware Interrupts – 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. Table 1 below shows the default IRQs in order of descending priority.

Software Interrupts – There is another type of interrupt that occurs in modern PCs; known as software interrupts. These are generated by the operating system, programs and various other software applications and 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.

Basic Input/Output System (BIOS) – 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.

BIOS Access – 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.

So whenever DOS, the operating system or other applications want to use a BIOS routine, it generates a software interrupt. The system processes the interrupt, looks 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 Bypass – More recently newer operating systems bypass the BIOS totally as this does help improve system performance.

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.

Legacy Devices Default Settings – 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.

Interrupt Summary – 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.

Read more:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s