All Topics  
Interrupt

 

   Email Print
   Bookmark   Link






 

Interrupt



 
 
In computing
Computing

Computing is usually defined as the activity of using and developing computer technology, computer hardware and computer software. It is the computer-specific part of information technology....
, an interrupt is an asynchronous
Asynchronous communication

In telecommunications, Asynchronous communication is transmission of data without the use of an external clock signal. Any timing required to recover data from the communication symbols is encoded within the symbols....
 signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change in execution. A hardware interrupt causes the processor
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 to save its state of execution via a context switch
Context switch

A context switch is the computing process of storing and restoring the State of a Central processing unit such that multiple Process es can share a single CPU resource....
, and begin execution
Execution (computers)

Execution in computer engineering and software engineering is the Process by which a computer or a virtual machine carries out the instructions of a computer program....
 of an interrupt handler
Interrupt handler

An interrupt handler, also known as an interrupt service routine , is a callback subroutine in an operating system or device driver whose execution is triggered by the reception of an interrupt....
. Software interrupts are usually implemented as instruction
Instruction (computer science)

In computer science, an instruction is a single operation of a central processing unit defined by an instruction set architecture. In a broader sense, an "instruction" may be any representation of an element of an executable program, such as a bytecode....
s in the instruction set
Instruction set

An instruction set is a list of all the instruction , and all their variations, that a processor can execute.Instructions include:* Arithmetic such as add and subtract...
, which cause a context switch to an interrupt handler similar to a hardware interrupt.






Discussion
Ask a question about 'Interrupt'
Start a new discussion about 'Interrupt'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computing
Computing

Computing is usually defined as the activity of using and developing computer technology, computer hardware and computer software. It is the computer-specific part of information technology....
, an interrupt is an asynchronous
Asynchronous communication

In telecommunications, Asynchronous communication is transmission of data without the use of an external clock signal. Any timing required to recover data from the communication symbols is encoded within the symbols....
 signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change in execution. A hardware interrupt causes the processor
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 to save its state of execution via a context switch
Context switch

A context switch is the computing process of storing and restoring the State of a Central processing unit such that multiple Process es can share a single CPU resource....
, and begin execution
Execution (computers)

Execution in computer engineering and software engineering is the Process by which a computer or a virtual machine carries out the instructions of a computer program....
 of an interrupt handler
Interrupt handler

An interrupt handler, also known as an interrupt service routine , is a callback subroutine in an operating system or device driver whose execution is triggered by the reception of an interrupt....
. Software interrupts are usually implemented as instruction
Instruction (computer science)

In computer science, an instruction is a single operation of a central processing unit defined by an instruction set architecture. In a broader sense, an "instruction" may be any representation of an element of an executable program, such as a bytecode....
s in the instruction set
Instruction set

An instruction set is a list of all the instruction , and all their variations, that a processor can execute.Instructions include:* Arithmetic such as add and subtract...
, which cause a context switch to an interrupt handler similar to a hardware interrupt. Interrupts are a commonly used technique for computer multitasking
Computer multitasking

In computing, multitasking is a method by which multiple tasks, also known as Computer process, share common processing resources such as a Central processing unit....
, especially in real-time computing. Such a system is said to be interrupt-driven.

An act of interrupting is referred to as an interrupt request
Interrupt request

The computing phrase "interrupt request" is used to refer to either the act of interrupting the Computer bus lines used to signal an interrupt, or the interrupt input lines on a Programmable Interrupt Controller ....
 ("IRQ").

Overview

Hardware interrupts were introduced as a way to avoid wasting the processor's valuable time in polling loops
Polling (computer science)

Polling, or polled operation, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity....
, waiting for external events. They may be implemented in hardware as a distinct system with control lines, or they may be integrated into the memory subsystem.

If implemented in hardware, an interrupt controller circuit such as the IBM PC's Programmable Interrupt Controller
Programmable Interrupt Controller

A programmable interrupt controller is a device which allows priority levels to be assigned to its interrupt outputs. When the device has multiple interrupt outputs to assert, it will assert them in the order of their relative priority....
 (PIC) may be connected between the interrupting device and the processor's interrupt pin to multiplex several sources of interrupt onto the one or two CPU lines typically available. If implemented as part of the memory controller, interrupts are mapped into the system's memory address space.

Interrupts can be categorized into: maskable interrupt (IRQ
Interrupt request

The computing phrase "interrupt request" is used to refer to either the act of interrupting the Computer bus lines used to signal an interrupt, or the interrupt input lines on a Programmable Interrupt Controller ....
), non-maskable interrupt
Non-Maskable interrupt

A non-maskable interrupt is a computer Central processing unit interrupt that cannot be ignored by standard interrupt masking techniques in the system....
 (NMI), interprocessor interrupt (IPI), software interrupt, and spurious interrupt.

  • A maskable interrupt (IRQ) is a hardware interrupt that may be ignored by setting a bit in an interrupt mask register's (IMR) bit-mask.


  • Likewise, a non-maskable interrupt
    Non-Maskable interrupt

    A non-maskable interrupt is a computer Central processing unit interrupt that cannot be ignored by standard interrupt masking techniques in the system....
    (NMI) is a hardware interrupt that does not have a bit-mask associated with it - meaning that it can never be ignored. NMIs are often used for timers, especially watchdog timer
    Watchdog timer

    A watchdog timer is a computer hardware timing device that triggers a system Reset if the main computer program, due to some fault condition, such as a hang , neglects to regularly service the watchdog ....
    s.


  • An interprocessor interrupt is a special case of interrupt that is generated by one processor to interrupt another processor in a multiprocessor system.


  • A software interrupt is an interrupt generated within a processor by executing an instruction. Software interrupts are often used to implement System call
    System call

    In computing, a system call is the mechanism used by an application program to request service from the kernel based on the Monolithic_kernel or to system servers on operating systems based on the microkernel-structure....
    s because they implement a subroutine call with a CPU ring level
    Ring (computer security)

    In computer science, hierarchical protection domains, often called protection rings, are a mechanism to protect data and functionality from faults and malicious behaviour ....
     change.


  • A spurious interrupt is a hardware interrupt that is unwanted. They are typically generated by system conditions such as electrical interference on an interrupt line or through incorrectly designed hardware.


Processors typically have an internal
interrupt mask which allows software to ignore all external hardware interrupts while it is set. This mask may offer faster access than accessing an interrupt mask register (IMR) in a PIC, or disabling interrupts in the device itself. In some cases, such as the x86 architecture, disabling and enabling interrupts on the processor itself acts as a memory barrier
Memory barrier

Memory barrier, also known as membar or memory fence, is a class of instruction s which cause a central processing unit to enforce an ordering constraint on Random access memory operations issued before and after the barrier instruction....
, in which case it may actually be slower.

An interrupt that leaves the machine in a well-defined state is called a precise interrupt. Such an interrupt has four properties:

  • The Program Counter (PC) is saved in a known place.


  • All instructions before the one pointed to by the PC have fully executed.


  • No instruction beyond the one pointed to by the PC has been executed (That is no prohibition on instruction beyond that in PC, it is just that any changes they make to registers or memory must be undone before the interrupt happens).


  • The execution state of the instruction pointed to by the PC is known.


An interrupt that does not meet these requirements is called an imprecise interrupt.

The phenomenon where the overall system performance is severely hindered by excessive amounts of processing time spent handling interrupts is called an interrupt storm
Interrupt storm

In operating systems, an interrupt storm is an event during which a processor receives an inordinate number of interrupts that consume the majority of the processor's time....
.

Types of Interrupts


Level-triggered

A level-triggered interrupt is a class of interrupts where the presence of an unserviced interrupt is indicated by a high level (1), or low level (0), of the interrupt request
Interrupt request

The computing phrase "interrupt request" is used to refer to either the act of interrupting the Computer bus lines used to signal an interrupt, or the interrupt input lines on a Programmable Interrupt Controller ....
 line. A device wishing to signal an interrupt drives the line to its active level, and then holds it at that level until serviced. It ceases asserting the line when the CPU commands it to or otherwise handles the condition that caused it to signal the interrupt.

Typically, the processor samples the interrupt input at predefined times during each bus cycle such as state T2 for the Z80 microprocessor. If the interrupt isn't active when the processor samples it, the CPU doesn't see it. One possible use for this type of interrupt is to minimize spurious signals from a noisy interrupt line: a spurious pulse will often be so short that it is not noticed.

Multiple devices may share a level-triggered interrupt line if they are designed to. The interrupt line must have a pull-down or pull-up resistor so that when not actively driven it settles to its inactive state. Devices actively assert the line to indicate an outstanding interrupt, but let the line float (do not actively drive it) when not signalling an interrupt. The line is then in its asserted state when any (one or more than one) of the sharing devices is signalling an outstanding interrupt.

This class of interrupts is favored by some because of a convenient behavior when the line is shared. Upon detecting assertion of the interrupt line, the CPU must search through the devices sharing it until one requiring service is detected. After servicing this device, the CPU may recheck the interrupt line status to determine whether any other devices also need service. If the line is now de-asserted, the CPU avoids checking the remaining devices on the line. Since some devices interrupt more frequently than others, and other device interrupts are particularly expensive, a careful ordering of device checks is employed to increase efficiency.

There are also serious problems with sharing level-triggered interrupts. As long as any device on the line has an outstanding request for service the line remains asserted, so it is not possible to detect a change in the status of any other device. Deferring servicing a low-priority device is not an option, because this would prevent detection of service requests from higher-priority devices. If there is a device on the line that the CPU does not know how to service, then any interrupt from that device permanently blocks all interrupts from the other devices.

The original PCI
Peripheral Component Interconnect

The PCI Local Bus , or Conventional PCI, is a computer bus for attaching computer hardware in a computer. These devices can take either the form of an integrated circuit fitted onto the motherboard itself, called a planar device in the PCI specification or an expansion card that fits into a socket....
 standard mandated shareable level-triggered interrupts. The rationale for this was the efficiency gain discussed above. (Newer versions of PCI allow, and PCI Express
PCI Express

Peripheral Component Interconnect Express , officially abbreviated as PCIe, is a computer expansion card standard designed to replace the older PCI Local Bus, PCI-X, and Accelerated Graphics Port standards....
 requires, the use of message-signalled
Interrupt

In computing, an interrupt is an asynchronous communication signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change in execution....
 interrupts.)

Edge-triggered

An edge-triggered interrupt is a class of interrupts that are signalled by a level transition on the interrupt line, either a falling edge (1 to 0) or a rising edge (0 to 1). A device wishing to signal an interrupt drives a pulse onto the line and then releases the line to its quiescent state. If the pulse is too short to be detected by polled I/O then special hardware may be required to detect the edge.

Multiple devices may share an edge-triggered interrupt line if they are designed to. The interrupt line must have a pull-down or pull-up resistor so that when not actively driven it settles to one particular state. Devices signal an interrupt by briefly driving the line to its non-default state, and let the line float (do not actively drive it) when not signalling an interrupt. This type of connection is also referred to as open collector
Open collector

File:opencollector.jpgOpen collector is a type of output on many Integrated circuits. Instead of outputting a signal of a specific voltage or current, the output signal is applied to the base of an internal Bipolar junction transistor#NPN whose collector is externalized on a pin of the IC....
. The line then carries all the pulses generated by all the devices. However, interrupt pulses from different devices may merge if they occur close in time. To avoid losing interrupts the CPU must trigger on the trailing edge of the pulse (e.g., the rising edge if the line is pulled up and driven low). After detecting an interrupt the CPU must check all the devices for service requirements.

Edge-triggered interrupts do not suffer the problems that level-triggered interrupts have with sharing. Service of a low-priority device can be postponed arbitrarily, and interrupts will continue to be received from the high-priority devices that are being serviced. If there is a device that the CPU does not know how to service, it may cause a spurious interrupt, or even periodic spurious interrupts, but it does not interfere with the interrupt signalling of the other devices. However, it is fairly easy for an edge triggered interrupt to be missed - for example if interrupts have to be masked for a period - and unless there is some type of hardware latch that records the event it is impossible to recover. Such problems caused many "lockups" in early computer hardware because the processor didn't know it was expected to do something. More modern hardware often has one or more interrupt status registers that latch the interrupt requests; well written edge-driven interrupt software often checks such registers to ensure events are not missed.

The elderly ISA
Industry Standard Architecture

Industry Standard Architecture was a computer bus standard for IBM compatible computers....
 bus uses edge-triggered interrupts, but does not mandate that devices be able to share them. The parallel port
Parallel port

A parallel port is a type of interface found on computers for connecting various peripherals. It is also known as a printer port or Centronics#The interface....
 also uses edge-triggered interrupts. Many older devices assume that they have exclusive use of their interrupt line, making it electrically unsafe to share them. However, ISA motherboards include pull-up resistors on the IRQ lines, so well-behaved devices share ISA interrupts just fine.

Hybrid

Some systems use a hybrid of level-triggered and edge-triggered signalling. The hardware not only looks for an edge, but it also verifies that the interrupt signal stays active for a certain period of time.

A common use of a hybrid interrupt is for the NMI (non-maskable interrupt) input. Because NMIs generally signal major – or even catastrophic – system events, a good implementation of this signal tries to ensure that the interrupt is valid by verifying that it remains active for a period of time. This 2-step approach helps to eliminate false interrupts from affecting the system.

Message-signalled


A message-signalled interrupt does not use a physical interrupt line. Instead, a device signals its request for service by sending a short message over some communications medium, typically a computer bus
Computer bus

In computer architecture, a bus is a subsystem that transfers data between computer components inside a computer or between computers. Each bus defines its set of connectors to physically plug devices, cards or cables together....
. The message might be of a type reserved for interrupts, or it might be of some pre-existing type such as a memory write.

Message-signalled interrupts behave very much like edge-triggered interrupts, in that the interrupt is a momentary signal rather than a continuous condition. Interrupt-handling software treats the two in much the same manner. Typically, multiple pending message-signalled interrupts with the same message (the same virtual interrupt line) are allowed to merge, just as closely-spaced edge-triggered interrupts can merge.

Message-signalled interrupt vectors can be shared, to the extent that the underlying communication medium can be shared. No additional effort is required.

Because the identity of the interrupt is indicated by a pattern of data bits, not requiring a separate physical conductor, many more distinct interrupts can be efficiently handled. This reduces the need for sharing. Interrupt messages can also be passed over a serial bus, not requiring any additional lines.

PCI Express
PCI Express

Peripheral Component Interconnect Express , officially abbreviated as PCIe, is a computer expansion card standard designed to replace the older PCI Local Bus, PCI-X, and Accelerated Graphics Port standards....
, a serial computer bus, uses message-signalled interrupts
Message Signaled Interrupts

Message Signaled Interrupts, in Peripheral Component Interconnect 2.2and later and PCI Express, are an alternative way of generating an interrupt....
 exclusively.

Doorbell

In a push button analogy applied to computer systems, the term doorbell or doorbell interrupt is often used to describe a mechanism whereby a software system can signal or notify a hardware
Hardware

Hardware is a general term that refers to the physical cultural artifacts of a technology. It may also mean the physical components of a computer system, in the form of computer hardware....
 device that there is some work to be done. Typically, the software system will place data in some well known and mutually agreed upon memory location(s), and "ring the doorbell" by writing to a different memory location. This different memory location is often called the doorbell region, and there may even be multiple doorbells serving different purposes in this region. It's this act of writing to the doorbell region of memory that "rings the bell" and notifies the hardware device that the data is ready and waiting. The hardware device would now know that the data is valid and can be acted upon. It would typically write the data to a hard disk drive, or send it over a network
Computer network

A computer network is a group of interconnected computers. Networks may be classified according to a wide variety of characteristics. This article provides a general overview of some types and categories and also presents the basic components of a network....
, or encrypt it, etc.

The term doorbell interrupt is usually a misnomer
Misnomer

A misnomer is a term which suggests an interpretation that is known to be untrue. Such incorrect terms sometimes derived their names because of the form, action, or origin of the subject?becoming named popularly or widely referenced?long before their true natures were known....
. It's similar to an interrupt
Interrupt

In computing, an interrupt is an asynchronous communication signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change in execution....
 because it causes some work to be done by the device, however the doorbell region is sometimes implemented as a polled
Polling (computer science)

Polling, or polled operation, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity....
 region, sometimes the doorbell region writes through to physical device registers
Hardware register

In digital electronics, especially computing, a hardware register stores bits of information, in a way that all the bits can be written to or read out simultaneously....
, and sometimes the doorbell region is hardwired directly to physical device registers. When either writing through or directly to physical device registers, this may, but not necessarily, cause a real interrupt to occur at the device's central processor unit (CPU), if it has one.

Doorbell interrupts can be compared to Message Signaled Interrupts
Message Signaled Interrupts

Message Signaled Interrupts, in Peripheral Component Interconnect 2.2and later and PCI Express, are an alternative way of generating an interrupt....
, as they have some similarities.

Difficulty with sharing interrupt lines

Multiple devices sharing an interrupt line (of any triggering style) all act as spurious interrupt sources with respect to each other. With many devices on one line the workload in servicing interrupts grows in proportion to the square of the number of devices. It is therefore preferred to spread devices evenly across the available interrupt lines. Shortage of interrupt lines is a problem in older system designs where the interrupt lines are distinct physical conductors. Message-signalled interrupts, where the interrupt line is virtual, are favoured in new system architectures (such as PCI Express
PCI Express

Peripheral Component Interconnect Express , officially abbreviated as PCIe, is a computer expansion card standard designed to replace the older PCI Local Bus, PCI-X, and Accelerated Graphics Port standards....
) and relieve this problem to a considerable extent.

Some devices with a badly-designed programming interface provide no way to determine whether they have requested service. They may lock up or otherwise misbehave if serviced when they do not want it. Such devices cannot tolerate spurious interrupts, and so also cannot tolerate sharing an interrupt line. ISA
Industry Standard Architecture

Industry Standard Architecture was a computer bus standard for IBM compatible computers....
 cards, due to often cheap design and construction, are notorious for this problem. Such devices are becoming much rarer, as hardware logic becomes cheaper and new system architectures mandate shareable interrupts.

Typical uses

Typical uses of interrupts include the following: system timers, disks I/O, power-off signals, and traps
Exception handling

Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions - special conditions that change the normal flow of execution....
. Other interrupts exist to transfer data bytes using UARTs or Ethernet
Ethernet

Ethernet is a family of Data frame-based computer networking technologies for local area networks . The name comes from the physical concept of the Luminiferous aether....
; sense key-presses; control motors; or anything else the equipment must do.

A classic system timer interrupt interrupts periodically from a counter or the power-line. The interrupt handler counts the interrupts to keep time. The timer interrupt may also be used by the OS's task scheduler to reschedule the priorities of running process
Process (computing)

In computing, a process is an Object of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs Concurrency ....
es. Counters are popular, but some older computers used the power line frequency instead, because power companies in most Western countries control the power-line frequency with a very accurate atomic clock
Atomic clock

An atomic clock is a type of clock that uses an atomic resonance frequency standard as its timekeeping element. They are the most accurate time and frequency standards known, and are used as primary standards for international Time dissemination, and to control the frequency of television broadcasts and GPS satellite signals....
.

A disk interrupt signals the completion of a data transfer from or to the disk peripheral. A process waiting to read or write a file starts up again.

A power-off interrupt predicts or requests a loss of power. It allows the computer equipment to perform an orderly shutdown.

Interrupts are also used in typeahead
Typeahead

Typeahead is a feature of computers and software that enables users to continue typing regardless of program or computer operation?the user may type in whatever speed he desires, and if the receiving software is busy at the time it will be called to handle this later....
 features for buffering events like keystrokes.

See also

  • Advanced Programmable Interrupt Controller
    Advanced Programmable Interrupt Controller

    An Advanced Programmable Interrupt Controller is a more intricate Programmable Interrupt Controller containing a magnitude more outputs, much more complex priority schema, and Advanced IRQ management....
  • BIOS interrupt call
    BIOS interrupt call

    BIOS Interrupt Calls are a facility that DOS programs, and some other software such as boot loaders, use to invoke the BIOS's facilities. Some operating systems also use the BIOS to probe and initialise hardware resources during their early stages of booting....
  • Programmable Interrupt Controller
    Programmable Interrupt Controller

    A programmable interrupt controller is a device which allows priority levels to be assigned to its interrupt outputs. When the device has multiple interrupt outputs to assert, it will assert them in the order of their relative priority....
  • Inter-processor interrupt
    Inter-Processor Interrupt

    An inter-processor interrupt is a special type of interrupt by which one processor may interrupt another processor in a multiprocessor system. IPIs are typically used to implement a cache coherency synchronization point....
  • Interrupt handler
    Interrupt handler

    An interrupt handler, also known as an interrupt service routine , is a callback subroutine in an operating system or device driver whose execution is triggered by the reception of an interrupt....
  • Interrupt latency
    Interrupt latency

    In real-time operating systems, interrupt latency is the time between the generation of an interrupt by a device and the servicing of the device which generated the interrupt....
  • Non-maskable interrupt
    Non-Maskable interrupt

    A non-maskable interrupt is a computer Central processing unit interrupt that cannot be ignored by standard interrupt masking techniques in the system....
  • Ralf Brown's Interrupt List
    Ralf Brown's Interrupt List

    Ralf Brown's Interrupt List or RBIL is a list of interrupts for x86 computers using DOS. It was maintained by Ralf Brown, a researcher at Carnegie Mellon University's Language Technologies Institute....


External links