Interrupts in Computer

What are Interrupts in Computer?

Interrupts in the computer are the signals generated either by hardware or by software and are sent to the processor, informing it that an event needs its instant attention. It causes the processor to stop whatever it is doing and service the interrupt.

We know that a processor can serve only one process at a time. It is due to interrupts that the processor provides you with the illusion of multitasking. Actually, the processor is serving the processes in a time-sharing fashion using interrupt schedules.

Let us take an example, a process has entered a wait loop and is waiting for the I/O device to get ready. At this moment, the processor is not performing any useful computation. It can be utilized to perform other tasks. For this, the I/O device must send an alert when it is ready, and it can be done by sending the interrupt signal to the processor.

Now, the processor does not have to check the status of the I/O device. This is because it would alert the processor when it is ready, and the processor can perform some other task. So, with the help of interrupts, the waiting period of the processor can be eliminated easily.

Table of Contents

  1. Types
  2. Interrupt Handler Working
  3. EnablingandDisablingInterrupt

Types of Interrupts in Computer

types-of-interrupts-in-computer-architecture

Hardware Interrupt

The interrupt signal generated from the hardware device is the hardware interrupt. For example, the processor executes some task, and in the middle of that, you double-click on an app to open it. The click would generate a signal to the processor to open the corresponding app.

The Hardware interrupt is further classified as a maskable and non-maskable interrupt. The maskable interrupts are the ones that other high-priority interrupts can delay.

The non-maskable interrupt is one which is high priority interrupts any other interrupt cannot delay that. Further, it has to be serviced by the processor immediately.

Must Read: Malware in Computer

Software Interrupt

A software application generates software interrupts. For example, if the software is expecting a valid number and it receives a null value, then it generates an interrupt to prevent the application from crashing.

The software interrupt can also be classified into two types, i.e., normal interrupt and exception. Interrupts generated by the software program instruction is a normal interrupts. The unexpected interrupt generated during the execution of the program is an exception.

Interrupt Handler Working

Whenever the interrupt occurs, it invokes a series of events which are discussed below in steps:

  1. Consider that the process is executing the ith instruction and the program counter has the address of i+1th instruction, and at this moment, the interrupt occurs.
  2. As soon as the interrupt occurs, the address in the program counter is stored in the process stack and now the program counter stores the interrupt service routine.
  3. After the completion of the interrupt service routine, the program counter is again loaded with the address of that i+1th instruction which processor was executing earlier. So, the processor resumes the execution of the i+1th instruction.

Must Read: Registers in Computer

Enabling and Disabling Interrupt

An interrupt can be raised at any moment. Further,  it would cause the processor to suspend the currently executing process and attend to the occurred interrupt immediately. The unplanned occurrence of an interrupt can alter the sequence of events predicted by the programmer.

To have control over the interrupt occurrence, all the computers have a fundamental facility that allows the user to enable or disable the occurrence of interrupts.

The user can enable or disable the occurrence of interrupts either at the processor end or at the I/O device end. The processor can be enabled to attend to the interrupt immediately or can be disabled to delay the interrupt. Similarly, the I/O devices can be enabled to raise the interrupt, or they can be disabled to raise any interrupt.

In this context, we have seen interrupts in brief. Also, we have covered how the processors attend to the interrupts. So, this is how the interrupts in the computer are the key feature of every operating system, which helps the operating system multitask.

Leave a Reply

Your email address will not be published.