关于interrupt与timer-driven 驱动的整合

1797阅读 0评论2009-05-11 linuxmemo
分类:LINUX

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章。
上一篇:(转载)ubuntu下获得命令对应的源码
下一篇:查看磁盘情况