Understanding Linux Network Internals 的9.2章提到:
纯interrupt的驱动在中断数很多的时候系统cpu利用率很高,cpu被中断处理程序占用,而收上来的报文没办法处理。而timer-driven类型的驱动在报文很多的情况下也能工作良好,但报文不多时却有较大的延迟。
这两种驱动可以整合起来:
A good combination would use the interrupt technique under low load and switch
to the timer-driven interrupt under high load.
还举了个例子:
static irqreturn_t vortex_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
int work_done = max_interrupt_work;
ioaddr = dev->base_addr;
... ... ...
status = inw(ioaddr + EL3_STATUS);
do {/*do语句内:一个中断收多个报文,报文太多则变成timer-driven*/
... ... ...
if (status & RxComplete)
vortex_rx(dev);
if (--work_done < 0) {/*if语句内:报文很多,实现timer-driven*/
/* Disable all pending interrupts. */
... ... ...
/* The timer will re-enable interrupts. */
mod_timer(&vp->timer, jiffies + 1*HZ);
break;
}
... ... ...
} while ((status = inw(ioaddr + EL3_STATUS)) & (IntLatch | RxComplete));
... ... ...
}
|
timer-driven方式的驱动可以看9.2章。
阅读(1784) | 评论(0) | 转发(0) |