IRQ
An IRQ (Interrupt Request) is a hardware signal that allows a device, like a keyboard or hard drive, to interrupt the CPU and request its attention. This system prevents the CPU from being overwhelmed by all devices demanding service at once by assigning each device a unique IRQ number. When a device needs service, it sends a signal on its dedicated IRQ line; the CPU then finishes its current task, handles the request, and resumes its original work.
How IRQs work
Request for service: A peripheral device, such as a printer, network card, or mouse, sends a signal to the CPU via a specific IRQ line when it needs attention.
CPU interruption: The CPU temporarily suspends its current task to handle the request.
IRQ handler: The CPU jumps to a specific routine called an IRQ handler to process the interrupt.
Resumption: After processing the request, the CPU restores its previous state and resumes the interrupted task.
Priority: IRQs are prioritized. Lower IRQ numbers typically have higher priority, ensuring critical tasks like the system timer (IRQ0) are handled immediately.