Table of contents
1.
Introduction
2.
What is Interrupt?
3.
Types of interrupts
3.1.
Hardware Interrupt
3.1.1.
Internal Interrupts
3.1.2.
External Interrupts
3.2.
Software interrupt
3.2.1.
Normal Interrupts
3.2.2.
Exception Interrupts
4.
Understanding interrupts and how the CPU handles them
5.
What is Interrupt Latency?
6.
Triggering Methods
7.
Benefits of Interrupt
8.
Frequently Asked Questions
8.1.
What is an interrupt with an example?
8.2.
What are the types of interrupt?
8.3.
What is interrupt processing in computer architecture?
8.4.
What is the use of interrupts in computer architecture?
8.5.
When should interrupts be used?
9.
Conclusion
Last Updated: May 19, 2024
Easy

Interrupt in Computer Architecture

Author SHIKHAR SONI
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

The word `interrupt` generally refers to stopping an ongoing process temporarily. The idea behind interrupts in computer architecture is very similar. Here when we receive an interrupt we stop the currently running process and instead service the interrupt (such as a keypress on the keyboard) first.

Interrupt in Computer Architecture

What is Interrupt?

Before interrupts, the CPU had to wait for the signal to process by continuously checking for related hardware and software components (a method used earlier, referred to as "polling"). This method expends CPU cycles waiting, reducing our efficiency. The effective usage time of the CPU is reduced, reducing response time, and there's also increased power consumption.

The solution proposed to the above problem was the use of interrupts. In this method, instead of constantly checking for a signal, the CPU receives a signal from the hardware or software components. The process of sending the signal by hardware or software components is referred to as sending interrupts or interrupting the system.

The interrupts divert the CPU's attention to the signal request from the running process. Once the interrupt signal is handled, the control is transferred back to the previous process to continue from the exact position where it had left off.

Read About - Shift Registers in Digital Electronics

Types of interrupts

The interrupts are of two types:

1. Hardware interrupt

2. Software interrupt

Hardware Interrupt

Interrupts generated by the hardware are referred to as hardware interrupts. The failure of hardware components and the completion of I/O can trigger hardware interrupts.

The two subtypes under it are:

1. Internal Interrupts

2. External Interrupts

Internal Interrupts

These interrupts occur when there is an error due to some instruction. For example, overflows (register overflow), incorrect instructions code, etc.

These types of interrupts are commonly referred to as traps.

External Interrupts

These interrupts are the ones issued by hardware components, For example, when the I/O process is completed data transfer, an infinite loop in the given code, power failure, etc.

Software interrupt

As the name suggests, these interrupts are caused by software, mostly in user mode. When a software interrupt occurs, the control is handed over to an interrupt handler (a part of the Operating System). Termination of programs or requests of certain services like the output to screen or using the printer can trigger it. These interrupts also have higher priority than hardware interrupts.

There are two types of software interrupts:

  • Normal Interrupts
  • Exception Interrupts

Normal Interrupts

These interrupts are caused by software instructions and are made intentionally.

Exception Interrupts

These interrupts are unplanned that occur during the execution of the program. An example of this is the divide by zero exception.

Must Read hardwired and microprogrammed control unit

Understanding interrupts and how the CPU handles them

Let's assume there is a program composed of many instructions where we are processing the instructions one by one. Eventually, we have reached a certain instruction, and an interrupt occurs. Interrupts can occur for various reasons, for example, if you have a program that does the 'X' thing when the user presses the 'A' key on the keyboard. If we press the key 'A', the normal flow of the program has to be interrupted to process this new signal and do the 'X' thing. Later, we return to executing the instructions from where we left off before the previous process's interruption.

After the interrupt has occurred, the CPU needs to pass the control from the current process to service the interrupts instead of moving to the next instruction in the current process. Before transferring the control over to the interrupt generated program, we need to store the state of the currently running process.

The summary of the process followed during an interrupt is as below:

1. While executing some instructions of a process, an interrupt is issued.

2. Execution of the current instruction is completed, and the system responds to the interrupt.

3. The system sends an acknowledgement for the interrupt, and the interrupt signal from the source stops on receiving the acknowledgement.

4. The process's state of the current task is stored (register values, address of the next instruction to be processed when the control comes back to the process (Program counter in PC register), etc.), i.e., moved to the stack.

5. The processor now handles the interrupt and executes the interrupt generated program.

6. After handling the interrupt, the control is sent back to the point in the original process using the state information of the process that we saved earlier.

What is Interrupt Latency?

Interrupt latency is the time delay between the occurrence of an interrupt signal and the start of the execution of the corresponding interrupt service routine (ISR). It encompasses the time taken by the processor to recognize the interrupt, complete the current instruction, save the necessary state, and begin executing the ISR. Minimizing interrupt latency is crucial in real-time systems where timely response to external events is essential for maintaining system stability and performance.

Triggering Methods

Interrupts can be triggered using various methods, including:

  • Edge Triggering: An interrupt is generated when a signal transitions from one state to another, such as from low to high (rising edge) or high to low (falling edge). Edge triggering is useful for detecting changes in state.
  • Level Triggering: An interrupt is generated when a signal is at a specific level, either high or low, for a certain period. Level triggering is beneficial for detecting steady-state conditions.
  • Software Triggering: Interrupts can also be initiated by software through specific instructions or commands. This method allows greater flexibility and control within the software environment.
  • Priority Triggering: Some systems implement priority-based triggering, where higher-priority interrupts can preempt lower-priority ones. This ensures that critical tasks are handled promptly.

Benefits of Interrupt

Interrupts offer several advantages in system design:

  • Efficiency: By using interrupts, the CPU can perform other tasks instead of constantly polling for events. This increases overall system efficiency and allows for better utilization of processing resources.
  • Responsiveness: Interrupts enable the system to respond quickly to external events. This is particularly important in real-time applications where delays can lead to system failures or degraded performance.
  • Modularity: Interrupts support modular design by allowing different parts of a system to handle specific events independently. This separation of concerns can simplify development and maintenance.
  • Power Saving: In low-power systems, interrupts can help conserve energy by allowing the CPU to enter low-power modes when idle and wake up only when an interrupt occurs, reducing overall power consumption.

Frequently Asked Questions

What is an interrupt with an example?

An interrupt is a signal that temporarily halts a CPU's current activities to execute a specific service routine. For example, pressing a key on a keyboard generates an interrupt to process the keystroke.

What are the types of interrupt?

Interrupts can be classified into hardware interrupts, triggered by external devices, and software interrupts, initiated by program instructions. Hardware interrupts include timers and I/O devices, while software interrupts include system calls and exceptions.

What is interrupt processing in computer architecture?

Interrupt processing involves the CPU recognizing an interrupt, saving its current state, executing an interrupt service routine (ISR) to address the interrupt, and then restoring its state to resume normal operations.

What is the use of interrupts in computer architecture?

Interrupts allow a computer to respond promptly to external events, improve CPU efficiency by reducing polling, and support real-time processing by ensuring critical tasks are addressed immediately.

When should interrupts be used?

Interrupts should be used when immediate attention to external events is necessary, such as in real-time systems, to handle asynchronous events efficiently, and to improve overall system responsiveness and performance.

Conclusion

The article covers Interrupts, their importance, how they work and the real-world problem they solve. Interrupts are one of the most fundamental topics in Computer Architecture and Operating Systems. Refer to the following article here about process management and here for understanding states in a process.

To know more about Computer Architecture and Organization, refer to the articles here. The link covers all the prerequisite knowledge to help you understand this article better and more.

Visit the link here for carefully crafted courses on campus placement and interview preparation on coding ninjas.

Happy learning!

Live masterclass