What is an interrupt and how does the processor handle normal and multiple interrupts?


An interrupt is a signal from a device attached to a computer or from a program within the computer that requires the operating system to stop and figure out what to do next.

Whenever an interrupt occurs, it causes the CPU to stop executing the current program. Then comes the control to interrupt the handler or interrupt service routine.

The steps in which ISR handle interrupts are as follows −

  • Step 1 − When an interrupt occurs let assume processor is executing i'th instruction and program counter will point to the next instruction (i+1)th.

  • Step 2 − When an interrupt occurs the program value is stored on the process stack and the program counter is loaded with the address of interrupt service routine.

  • Step 3 − Once the interrupt service routine is completed the address on the process stack is popped and placed back in the program counter.

  • Step 4 − Now, it executes the resume for (i+1)th line.

Multiple interrupts

Multiple interrupt is an interrupt event which can occur while the processor is handling a previous interrupt.

For example − A program receiving data from a communication line and printing result there is a possibility for communication interrupt to occur while printer interrupt being processed.

Ways to handle interrupts

There are two ways by which processor can handle interrupts

  • Disable interrupt − Processor will ignore further interrupts while processing one interrupt. Interrupts remain pending and are checked after the first interrupt has been handled. In this process interrupts are handled in sequence

  • Define priorities − In this method low priority interrupts can be interrupted by higher priority interrupts. Here, high priority interrupt will be handled then processor returns to previous interrupt on which it was earlier working.

Types of interrupts

There are two types of interrupts −

  • Hardware interrupts − Interrupt signal generated from external devices.

  • Software interrupts − Interrupt signal generated from internal devices.

We know that the instruction cycle consists of fetch, decode, execute and read/write functions.

After every instruction cycle, the processor will check for interrupts to be processed. If no interrupt is present in the system it will go for the next instruction cycle which is given by the instruction register.

If there is an interrupt present then it will trigger the interrupt handler, the handler will stop the present instruction which is processing and save its configuration in a register and load the program counter of the interrupt from a location which is given by the interrupt table.

After processing the interrupt the processor interrupt handler will load the instruction and its configuration from the saved register, the process will start its processing where it’s left. This is also called context switching.

Updated on: 26-Nov-2021

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements