In: Computer Science
Explain how the interrupt mechanism works in Unix? Use a clear and concise diagram.
Interrupt :-
The interrupt is an event that changes the instructions sequence executed by the processor.
There are two types of interrupts:
Synchronous interrupt (Exception) the interrupt produced by the CPU while processing instructions is known as Exception
Asynchronous interrupt (Interrupt) the interrupt issued by other hardware devices
Exceptions are created by programming errors like Divide error, Page Fault, Overflow etc that must be handled by the kernel. He sends a signal to the program and tries to recover from the error.
Interrupts can be issued by input output devices such as keyboard, network adapter,etc When an interrupt occures, the CPU stop his current instruction and execute the newly arrived interrupt.CPU also need to save the old interrupted process state to resume it after the interrupt is handled.
There are two different interrupt levels are defined:
Maskable interrupts:- Interrupts issued by I/O devices; can be in two states, masked or unmasked. Only unmasked interrupts are getting processed.
Nonmaskable interrupts:- Interrupts critical malfunctions such as hardware failure ,etc are always processed by the CPU.
Every hardware device in the computer has it's own Interrupt
Request (IRQ) line. The IRQs are numbered starting from 0. All IRQ
lines are connected to a Programmable Interrupt Controller (PIC).
The PIC listens on IRQs and assigns them to the CPU. It is also
possible to disable a specific IRQ line through program.
Modern multiprocessing Linux systems generally include the newer
Advanced PIC (APIC), which distributes IRQ requests equally between
the CPUs.
The mid-step between an interrupt or exception and the handling of it is the Interrupt Descriptor Table (IDT). This table associates each interrupt or exception vector (a number) with a specified handler for example Divide error gets handled by the function divide_error()
Through the IDT, the kernel knows exactly how to handle the occurred interrupt or exception.
The Step that Kernal follows when receive the interrupt
Flow :-