Interrupt !!
Processors need to detect hardware activities. There are multiple solutions to detect hardware activities. For example, Let's consider polling.? In polling every repeated time, hardware status will get verified without knowing whether the device is active or ready. It is an overhead process to detect the hardware status.
The better solution is that hardware should provide the signal to the processor about activities to gain the attention of the processor when it really required. This mechanism is called an interrupt.?
The hardware generates interrupts asynchronously and helps to gain the attention of the CPU to process its handler.? An interrupt is produced by electronic signals from hardware devices and directed into input pins on an interrupt controller.?
1) After receiving the interrupt, the interrupt controller will send a signal to the processor.
2) Processor detects the singal and halts the current execution context.?
3) Processor will notify the operating system about the incoming interrupt to handle further.?
4) Operating system will call the interrupt handler or routines which further resolved the interrupt.?
5) Operating system notifies back about the Interrupt completion to resume the saved contexts
Different devices are associated with different interrupts. Each interrupt is identified by a unique number or value. This will operating system to distinguish interrupts and call the appropriate interrupt handler. These interrupt values are also called IRQ Lines ( Interrupt Request Lines).
领英推荐
The kernel handles the interrupt with the following sequence of operations
The interrupt handler is also called an "Interrupt Service Routine" (ISR). In Linux, interrupt handlers are normal C functions, which match a specific prototype and thus enable the kernel to pass the handler information in a standard way. What differentiates interrupt handlers from other kernel functions is that the kernel invokes them in response to interrupts and that they run in a special context called interrupt context. This special context is occasionally called atomic context because code executing in this context is unable to block.
Registration of Interrupt and Handler:
Devices come with the device driver. If the device?uses the interrupt, then it will get register the interrupt handler. Drivers can register an interrupt handler and enable a given interrupt line for handling with the function request_irq(), which is declared in <linux/interrupt.h>.
int request_irq(unsigned int irq
? ? ? ? ? ? ? ? irq_handler_t handler,
? ? ? ? ? ? ? ? unsigned long flags,
? ? ? ? ? ? ? ? const char *name,
? ? ? ? ? ? ? ? void *dev),
4. name of the device associated with the interrupt.
5. used for shared interrupt lines
Continue.....