The Wayback Machine - https://web.archive.org/web/20241009195518/https://www.geeksforgeeks.org/interrupts/
Open In App

What is an Interrupt?

Last Updated : 27 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Interrupts play a crucial role in computer devices by allowing the processor to react quickly to events or requests from external devices or software. In this article, we are going to discuss every point about interruption and its various types in detail.

What is an Interrupt?

The interrupt is a signal emitted by hardware or software when a process or an event needs immediate attention. It alerts the processor to a high-priority process requiring interruption of the current working process. In I/O devices one of the bus control lines is dedicated for this purpose and is called theInterrupt Service Routine (ISR). 

Interrupts play a key role in managing CPU tasks and system performance. If you’re preparing for GATE or simply want to master operating systems, the GATE CS Self-Paced Course offers a solid foundation.

When a device raises an interrupt at let’s say process i, the processor first completes the execution of instruction i. Then it loads the Program Counter (PC) with the address of the first instruction of the ISR. Before loading the Program Counter with the address, the address of the interrupted instruction is moved to a temporary location. Therefore, after handling the interrupt the processor can continue with process i+1. 

While the processor is handling the interrupts, it must inform the device that its request has been recognized so that it stops sending the interrupt request signal. Also, saving the registers so that the interrupted process can be restored in the future, increases the delay between the time an interrupt is received and the start of the execution of the ISR. This is called Interrupt Latency. 

Types of Interrupt

Event-related software or hardware can trigger the issuance of interrupt signals. These fall into one of two categories: software interrupts or hardware interrupts.

1. Software Interrupts

A sort of interrupt called a software interrupt is one that is produced by software or a system as opposed to hardware. Traps and exceptions are other names for software interruptions. They serve as a signal for the operating system or a system service to carry out a certain function or respond to an error condition. Generally, software interrupts occur as a result of specific instructions being used or exceptions in the operation. In our system, software interrupts often occur when system calls are made. In contrast to the fork() system call, which also generates a software interrupt, division by zero throws an exception that results in the software interrupt.

A particular instruction known as an “interrupt instruction” is used to create software interrupts. When the interrupt instruction is used, the processor stops what it is doing and switches over to a particular interrupt handler code. The interrupt handler routine completes the required work or handles any errors before handing back control to the interrupted application.

2. Hardware Interrupts

In a hardware interrupt, all the devices are connected to the Interrupt Request Line. A single request line is used for all the n devices. To request an interrupt, a device closes its associated switch. When a device requests an interrupt, the value of INTR is the logical OR of the requests from individual devices. 

Hardware interrupts are further divided into two types of interrupt

  • Maskable Interrupt: Hardware interrupts can be selectively enabled and disabled thanks to an inbuilt interrupt mask register that is commonly found in processors. A bit in the mask register corresponds to each interrupt signal; on some systems, the interrupt is enabled when the bit is set and disabled when the bit is clear, but on other systems, the interrupt is deactivated when the bit is set.
  • Spurious Interrupt: A hardware interrupt for which there is no source is known as a spurious interrupt. This phenomenon might also be referred to as phantom or ghost interrupts. When a wired-OR interrupt circuit is connected to a level-sensitive processor input, spurious interruptions are typically an issue. When a system performs badly, it could be challenging to locate these interruptions.

Sequences of Events Involved in Handling an IRQ(Interrupt Request)

  • Devices raise an IRQ.
  • The processor interrupts the program currently being executed.
  • The device is informed that its request has been recognized and the device deactivates the request signal.
  • The requested action is performed.
  • An interrupt is enabled and the interrupted program is resumed.

Flowchart of Interrupt Handling Mechanism

The Image below depicts the flowchart of interrupt handling mechanism

Flowchart

Step 1:- Any time that an interrupt is raised, it may either be an I/O interrupt or a system interrupt.

Step 2:- The current state comprising registers and the program counter is then stored in order to conserve the state of the process.

Step 3:- The current interrupt and its handler is identified through the interrupt vector table in the processor.

Step 4:- This control now shifts to the interrupt handler, which is a function located in the kernel space.

Step 5:- Specific tasks are performed by Interrupt Service Routine (ISR) which are essential to manage interrupt.

Step 6:- The status from the previous session is retrieved so as to build on the process from that point.

Step 7:- The control is then shifted back to the other process that was pending and the normal process continues.

Managing Multiple Devices

When more than one device raises an interrupt request signal, then additional information is needed to decide which device to be considered first. The following methods are used to decide which device to select: Polling, Vectored Interrupts, and Interrupt Nesting. These are explained below. 

  • Polling: In polling, the first device encountered with the IRQ bit set is the device that is to be serviced first. Appropriate ISR is called to service the same. It is easy to implement but a lot of time is wasted by interrogating the IRQ bit of all devices.
  • Vectored Interrupts: In vectored interrupts, a device requesting an interrupt identifies itself directly by sending a special code to the processor over the bus. This enables the processor to identify the device that generated the interrupt. The special code can be the starting address of the ISR or where the ISR is located in memory and is called the interrupt vector.
  • Interrupt Nesting: In this method, the I/O device is organized in a priority structure. Therefore, an interrupt request from a higher-priority device is recognized whereas a request from a lower-priority device is not.  The processor accepts interrupts only from devices/processes having priority.

Processors’ priority is encoded in a few bits of PS (Process Status register). It can be changed by program instructions that are written into the PS. The processor is in supervised mode only while executing OS routines. It switches to user mode before executing application programs.

What is Interrupt Latency?

The amount of time between the generation of an interrupt and its handling is known as interrupt latency. The number of created interrupts, the number of enabled interruptions, the number of interrupts that may be handled, and the time required to handle each interrupt all affect interrupt latency. When the device generating the interrupt needs a specific length of time to generate the interrupt, interrupt latency is required. For instance, if a printer is printing paper, the computer needs to stop the printing program and wait for the document to finish printing. The interrupt latency is the amount of time the computer has to stop the program from operating.

How CPU React when Interrupt occurs?

  • Interrupt Detection: The CPU continuously video displays unit interrupt lines or alerts from diverse resources, consisting of hardware gadgets or software program commands, to hit upon interrupt requests.
  • Interrupt Acknowledgment: Upon detecting an interrupt request, the CPU acknowledges the interrupt using sending an acknowledgment sign to the interrupting device or software program.
  • Interrupt Handling: The CPU identifies the form of interrupt primarily based on its supply, together with a hardware interrupt from a device or a software interrupt from a training. It then seems the cope with the corresponding interrupt handler habitual within the interrupt vector desk.
  • Context Saving: Before moving manipulate to the interrupt handler ordinary, the CPU saves the present-day execution context, inclusive of the program counter (PC), processor state, and any applicable sign-in contents, onto the stack or in the devoted garage.
  • Transfer Control: The CPU transfers manipulation to the interrupt handler ordinary with the aid of placing this system counter (PC) to the address of the handler habitual retrieved from the interrupt vector desk.
  • Interrupt Servicing: The interrupt handler habitual executes to carrier the interrupt. It plays responsibilities to interrupt, such as reading facts from a device, processing enter/output operations, or coping with a software program request.

Triggering Methods

Every interrupt signal input is intended to be activated by a certain signal edge (level change) or a logic signal level. Level-sensitive inputs make constant requests for processor attention as long as they are treated with a specific logic level (high or low). Edge-sensitive inputs are responsive to signal edges; a service request will latch on to a specific (rising or falling) edge. When the interrupt handler runs, the CPU resets the latch.

  • Level-Trigger: The interrupt signal must be held at its specific active logic level (high or low) to request a level-triggered interrupt. A level-triggered interrupt is triggered when a device drives the signal to the active level and maintains it there. When the CPU instructs it to do so, usually after the device has been serviced, it denies the signal.
  • Edge-Trigger: An interrupt that is caused by a level change on the interrupt line—either a rising or lowering edge—is known as an edge-triggered interrupt (low to high). A pulse is driven onto the line and released to its inactive state by a device that wishes to indicate an interrupt. It can be necessary to use specialized hardware to detect the pulse if polled I/O is unable to pick it up due to its short duration.

Benefits of Interrupt

  • Real-time Responsiveness: Interrupts permit a system to reply promptly to outside events or signals, permitting real-time processing.
  • Efficient Resource usage: Interrupt-driven structures are more efficient than system that depend on busy-waiting or polling strategies. Instead of continuously checking for the incidence of event, interrupts permit the processor to remain idle until an event occurs, conserving processing energy and lowering energy intake.
  • Multitasking and Concurrency: Interrupts allow multitasking with the aid of allowing a processor to address multiple tasks concurrently.
  • Improved system Throughput: By coping with occasions asynchronously, interrupts allow a device to overlap computation with I/O operations or other responsibilities, maximizing system throughput and universal overall performance.

Conclusion

  • The events known as interrupts alert the CPU to handle the request.
  • Both software and hardware can create interruptions.
  • Maskable and non-maskable interrupts are the two categories of hardware interrupts.
  • Generally speaking, exceptions and special instructions like fork() are what trigger software interrupts.
  • After completing the service request and handling the interruption, the CPU continues the process where it left off.

Frequently Asked Questions on Interrupt – FAQs

How are interrupts handled in the system?

An interrupt handler is a specialised piece of software that manages interruptions on a computer. On a computer, many interrupt handlers may be installed. The type of interrupt that is created determines which interrupt handler the CPU executes.

Can interruptions be prioritized?

Yes interrupts be prioritized.

What is the interrupt vector table?

The interrupt vector table, also known as the IV or IVT, is a list of functions that the CPU has linked to handle particular exceptions including faults, interrupt requests from peripherals, and system service requests from the application.

Why is the interrupt vector table stored in kernel rather than user memory?

The interrupt vector table is residing in kernel memory for security and stability reasons. Kernel memory is protected from user-space modifications to prevent important system functions from either malicious or accidental interference by user-space applications.

What are nested interrupts?

Whenever an ISR is being executed, an interrupt is permitted at any time and anywhere in a hierarchical interrupt system. However, only the most urgent ISRs would be carried out right away. After the highest priority ISR is finished, the second-highest priority one will be carried out. this is know as nested interrupt.



Similar Reads

Difference Between Hardware Interrupt and Software Interrupt
In a computer system, an interrupt is a signal that temporarily halts the CPU's current activities to give attention to something more urgent. This helps the computer respond quickly to important events. In this article, we are going to discuss what is hardware and software interrupts, and the difference between hardware and software interrupts in
4 min read
Return from Subroutine and Return from Interrupt
In this article, we will discuss the Return from Subroutine and Return from Interrupt and will explain in detail and finally conclude with Difference between Return from Subroutine and Return from Interrupt. Let's discuss it one by one. Return from Subroutine : To return from a subroutine is to return execution of code to the point it was before th
3 min read
Purpose of an Interrupt in Computer Organization
Interrupt is the mechanism by which modules like I/O or memory may interrupt the normal processing by CPU. It may be either clicking a mouse, dragging a cursor, printing a document etc the case where interrupt is getting generated. Why we require Interrupt? External devices are comparatively slower than CPU. So if there is no interrupt CPU would wa
2 min read
Difference between Interrupt and Exception
Prerequisite - Interrupts and Exceptions Interrupt is one of the classes of Exception. There are 4 classes of Exception- interrupt, trap, fault and abort. Though, interrupt belongs to exception still there are many differences between them. In any computer, during its normal execution of a program, there could be events that can cause the CPU to te
4 min read
ARM Interrupt Structure
A collection of reduced instruction set computer (RISC) instruction set architectures for computer processors that are tailored for different contexts is known as ARM (stylized in lowercase as an arm; originally an abbreviation for Advanced RISC Machines. System-on-a-chip (SoC) and system-on-module (SOM) designs, which combine various components in
7 min read
I/O Interface (Interrupt and DMA Mode)
The method that is used to transfer information between internal storage and external I/O devices is known as I/O interface. The CPU is interfaced using special communication links by the peripherals connected to any computer system. These communication links are used to resolve the differences between CPU and peripheral. There exists special hardw
6 min read
Difference between Maskable and Non Maskable Interrupt
An Interrupt is an event caused by a component other than the CPU. It indicates the CPU of an external event that requires immediate attention. Interrupts occur asynchronously. Maskable and non-maskable interrupts are two types of interrupts. What is Maskable Interrupt?An interrupt that can be disabled or ignored by the instructions of CPU are call
4 min read
Difference between Programmed and Interrupt Initiated I/O
Between CPU and I/O devices can be processed by several modes in the computer systems. There are two main ways that are used in I/O operations, and they include programmed I/O and interrupt initiated I/O. The decision on these modes has affected the performance of the system. The reader will find in this article a comparison of the operation of the
6 min read
GATE CS Notes (According to GATE 2025 Syllabus)
GATE stands for Graduate Aptitude Test in Engineering . GATE is a national-level exam conducted by IISc-Bangalore and the seven old IITs; GATE 2025 is going to be conducted by IIT Roorkee. The official notification of GATE 2025 has been released by IIT Roorkee. After clearing the GATE exam, candidates are eligible for Master of Technology (M.Tech)/
15+ min read
Computer Organization and Architecture Tutorial
In this Computer Organization and Architecture Tutorial, you’ll learn all the basic to advanced concepts like pipelining, microprogrammed control, computer architecture, instruction design, and format. Computer Organization and Architecture is used to design computer systems. Computer Architecture is considered to be those attributes of a system th
6 min read
DBMS Tutorial – Learn Database Management System
Database Management System is a software or technology used to manage data from a database. Some popular databases are MySQL, Oracle, MongoDB, etc. DBMS provides many operations e.g. creating a database, Storing in the database, updating an existing database, delete from the database. DBMS is a system that enables you to store, modify, and retrieve
8 min read
Operating System Tutorial
An Operating System(OS) is software that manages and handles the hardware and software resources of a computer system. It provides interaction between users of computers and computer hardware. An operating system is responsible for managing and controlling all the activities and sharing of computer resources. An operating system is a low-level Soft
7 min read
Computer Network Tutorial
A computer network is a collection of computers or devices connected to share resources. Any device which can share or receive the data is called a Node. Through which the information or data propagate is known as channels, It can be guided or unguided. In this Computer network tutorial, you’ll learn basic to advanced concepts like the Basics of co
10 min read
Top 100+ Computer Keyboard Shortcut Keys List (A to Z), PDF Available
Computer Shortcut Keys significantly enhance productivity and efficiency. These handy combinations of keys provide quick access to various functions and commands, allowing us to navigate in Computers. One must know Computer Shortcut keys to work more easily and quickly with computers. In this Computer Keyboard Shortcut Keys Guide, you will learn al
15+ min read
Memory Hierarchy Design and its Characteristics
In the Computer System Design, Memory Hierarchy is an enhancement to organize the memory such that it can minimize the access time. The Memory Hierarchy was developed based on a program behavior known as locality of references. The figure below clearly demonstrates the different levels of the memory hierarchy. Why Memory Hierarchy is Required in th
6 min read
Functions of Operating System
An Operating System acts as a communication bridge (interface) between the user and computer hardware. The purpose of an operating system is to provide a platform on which a user can execute programs conveniently and efficiently. An operating system is a piece of software that manages the allocation of Computer Hardware. The coordination of the har
12 min read
Difference Between IPv4 and IPv6
The address through which any computer communicates with our computer is simply called an Internet Protocol Address or IP address. For example, if we want to load a web page or download something, we require the address to deliver that particular file or webpage. That address is called an IP Address. There are two versions of IP: IPv4 and IPv6. IPv
7 min read
Types of Operating Systems
An Operating System performs all the basic tasks like managing files, processes, and memory. Thus, the operating system acts as the manager of all the resources, i.e. resource manager. Thus, the operating system becomes an interface between the user and the machine. It is one of the most required software that is present in the device. Operating Sy
11 min read
Types of Transmission Media
Transmission media refer to the physical pathways through which data is transmitted from one device to another within a network. These pathways can be wired or wireless. The choice of medium depends on factors like distance, speed, and interference. In this article, we will discuss the transmission media. What is Transmission Media? A transmission
8 min read
TCP/IP Model
The TCP/IP model is a fundamental framework for computer networking. It stands for Transmission Control Protocol/Internet Protocol, which are the core protocols of the Internet. This model defines how data is transmitted over networks, ensuring reliable communication between devices. It consists of four layers: the Link Layer, the Internet Layer, t
13 min read
What is OSI Model? - Layers of OSI Model
OSI stands for Open Systems Interconnection , where open stands to say non-proprietary. It is a 7-layer architecture with each layer having specific functionality to perform. All these 7 layers work collaboratively to transmit the data from one person to another across the globe. The OSI reference model was developed by ISO - 'International Organiz
15+ min read
Program for Decimal to Binary Conversion
Given a decimal number as input, we need to write a program to convert the given decimal number into an equivalent binary number. Examples of Decimal to Binary:  Input : 7Output : 111Input : 10Output : 1010Input: 33Output: 100001Recommended PracticeDecimal to binaryTry It!Brute force ApproachFor Example: If the decimal number is 10. Step 1: Remaind
15+ min read
Full Adder in Digital Logic
Full Adder is the adder that adds three inputs and produces two outputs. The first two inputs are A and B and the third input is an input carry as C-IN. The output carry is designated as C-OUT and the normal output is designated as S which is SUM. The C-OUT is also known as the majority 1's detector, whose output goes high when more than one input
5 min read
Multiplexers in Digital Logic
In this article we will go through the multiplexer, we will first define what is a multiplexer then we will go through its types which are 2x1 and 4x1, then we will go through the Implementation of the 2x1 mux and higher mux with lower order mux, At last we will conclude our article with some applications, advantages and some FAQs. Table of Content
11 min read
Types of Network Topology
Network topology refers to the arrangement of different elements like nodes, links, or devices in a computer network. It defines how these components are connected and interact with each other. Understanding various types of network topologies helps in designing efficient and robust networks. Common types include bus, star, ring, mesh, and tree top
12 min read
Types of Keys in Relational Model (Candidate, Super, Primary, Alternate and Foreign)
Keys are one of the basic requirements of a relational database model. It is widely used to identify the tuples(rows) uniquely in the table. We also use keys to set up relations amongst various columns and tables of a relational database. Different Types of Database Keys Candidate Key Primary Key Super Key Alternate Key Foreign Key Composite Key To
6 min read
ACID Properties in DBMS
This article is based on the concept of ACID properties in DBMS that are necessary for maintaining data consistency, integrity, and reliability while performing transactions in the database. Let's explore them. A transaction is a single logical unit of work that accesses and possibly modifies the contents of a database. Transactions access data usi
7 min read
Introduction of ER Model
Peter Chen developed the ER diagram in 1976. The ER model was created to provide a simple and understandable model for representing the structure and logic of databases. It has since evolved into variations such as the Enhanced ER Model and the Object Relationship Model The Entity Relational Model is a model for identifying entities to be represent
10 min read
Normal Forms in DBMS
Normalization is the process of minimizing redundancy from a relation or set of relations. Redundancy in relation may cause insertion, deletion, and update anomalies. So, it helps to minimize the redundancy in relations. Normal forms are used to eliminate or reduce redundancy in database tables. Normalization of DBMSIn database management systems (
12 min read
Network Devices (Hub, Repeater, Bridge, Switch, Router, Gateways and Brouter)
Network Devices: Network devices, also known as networking hardware, are physical devices that allow hardware on a computer network to communicate and interact with one another. For example Repeater, Hub, Bridge, Switch, Routers, Gateway, Brouter, and NIC, etc. 1. Repeater - A repeater operates at the physical layer. Its job is to amplifies (i.e.,
6 min read