Interrupt is a asynchronous signal (event) which generates from a hardware, informs to processor to handle some special activity which needs to be run atomically.
Please find below pictorial representation to understand,
When a hardware interrupt occurs,
- the processor halts (blocks) current executing tasks by saving the current state (by saving registers) and jumps to a predefined entry point. (This step usually in assembly and it is arch-dependent).
- From there OS takes the control, runs the 'C' runtime control point for all interrupt-handling- do_IRQ() which receives the saved registers as a parameter.
- From here, it extracts the IRQ number (from interrupt vector table - a variable 'vector'). do_IRQ now starts running interrupt context by calling irq_enter().
- It next runs the handle_irq() routine which processes the interrupt which calls interrupt service routine(s).
- Once handler done, irq_exit() exits interrupt context then kernel back to process context.
Basic call flow graph when an interrupt occurred:-
asm_do_IRQ() ← arch/arm/kernel/irq.c (generic assembly routine)
handle_IRQ() (generic C routine)
irq_enter()
generic_handle_IRQ() (here the specific ISR is handled)
irq_exit() (from here, return path to kernel process context)