IRQ共享原理

IRQ lines are a limited resource. A simple way to increase the number of devices a system can host is to allow multiple devices to share a common IRQ. Normally, each driver registers its own handler to the kernel for that IRQ. Instead of having the kernel receive the interrupt notification, find the right device, and invoke its handler, the kernel simply invokes all the handlers of those devices that registered for the same shared IRQ. It is up to the handlers to filter spurious invocations, such as by reading a registry on their devices.

--《Understanding Linux Network Internals》

当一个中断到来之后,内核会“唤醒”所有该中断的"订阅者",让他们各自查询自己的设备寄存器,以确定当前中断是不是自己的设备发出的。代价:每个订阅者都需要做一次查询。

因此,共享IRQ是需要付出代价的。对于慢速设备,这个代价可能很大。为了解决这一问题,这些设备可以将中断注册为不可共享的,其余“订阅者”想使用该中断的时候就会被拒绝。当然,这一方案并不治本,因为系统中断号总数量有限,不可能人人都注册成不可共享的形式。

你可能感兴趣的:(原理)