0
votes

in linux kernel development,i read about interrupt that when the kernel receives interrupt,it invokes sequentially each registered handler on the line.
My question is why kernel invokes other handler?

2
Well 1. because if something should happen as a reaction on an interrupt, then some code must be executed to "handle that interrupt" and 2. what is to happen is a dynamic thing, so stuff can be registered to happen. You cannot implement that in a static manner, since you don't know in advance what is required. This is not how computer systems work, that would make no sense.arkascha

2 Answers

0
votes

This is because several devices are sharing the same interrupt line. The only way the kernel can detect which handler to invoke is by passing the dev_id of the device to all the handlers which requires invoking the handler. The handler that was registered with the passed dev_id gets a match and it continues to run.

Remember, the handler was registered as:

static irqreturn_t intr_handler(int irq, void *dev_id, struct pt_regs *regs)

the handler was registered by passing the dev_id. So, that's the only thing that distinguishes devices on the same IRQ line.

0
votes

In a well define interrupt handler, specifically share the irq line, which will check whether the interrupt is raised by the specific device by reading some registers, and if it is, then handles the interrupt and return IRQ_HANDLED, or return IRQ_NONE to indicate that is not the device the handler servicing. So, it invokes sequentially each registered handler on the line until that the handler return IRQ_HANDLED meaning processing properly