Interrupt

Interrupt is a signal which has highest priority from hardware or software which processor should process immediately. There are three types of interrupt as given below.

1. Hardware Interrupt

2. Software Interrupt

3. Internal Interrupt (Exception)

So, we can easily understand the interrupt by the help of diagram.

Interrupt and Their Working

Interrupts and Their Working

Explanation

An interrupt changes the normal flow of system or program. When an interrupt occur the control is transferred to the interrupt vector that contain different interrupt handler. An interrupt handler deals with the cause of the interrupt. After solving the interrupt the interrupt handler return the control back to the CPU. It means that the control is return to the interrupted instructions. In the end, CPU start executing the suspended instructions.

Note: Each computer architecture has its own interrupt mechanism but they mostly work in their similar way.

Types of Interrupt

Types of interrupt are as given below.

1. Hardware Interrupt

A hardware interrupt occurs when a hardware device sends a signal to the processor to get attention. There are two types of hardware interrupt:

i) Maskable Interrupt (MI)

ii) Non-Maskable Interrupt (NMI)

Example

When we click on a mouse button than a mouse sends an interrupt signal to the CPU.

2. Software Interrupt

An software interrupt occurs when a programs calls a system service and asks the operating system to provide a service or to perform a task is called Software Interrupt. There are two types of software interrupt:

i) Normal Interrupt

ii) Exception Interrupt

Example

When we open a file, the program requests the operating system to access that file. This request can generate a software interrupt.

3. Internal Interrupt (Exception)

An internal interrupt occurs when an error or unusual condition happens inside the CPU while executing a program is called internal interrupt (exception).

There are three types of internal interrupt (exception)

i) Divide-by-Zero Exception

ii) Overflow Exception

iii) Invalid Opcode Exception

Example

When a program tries to divide a number by zero, however internal interrupt occurs.