StartIo例程的作用

 

 

关于驱动程序里StartIo例程的作用,部分摘自网络,有不正确的地方还望指正。

 

在很多时候,驱动程序不能立即处理I/O请求,此时需要通过一个队列保存Irp,然后返回,等到可以处理I/O请求时,再从队列中取出Irp进行处理。驱动程序可以自己维护一个队列,并通过系统线程来做处理。由于很多驱动程序都需要这种处理机制,为了方便处理,系统为此提供了一套处理机制,驱动程序可以调用IoStartPacket()将Irp放入系统提供的设备队列里面,系统会依次调用驱动程序的StartIo函数逐一处理这些Irp。

 

Because the I/O manager supports asynchronous I/O within a multitasking and multithreaded system, I/O requests to a device can come in faster than its driver can process them to completion, particularly in multiprocessor machines. Consequently, IRPs bound to any particular device must be queued in the driver when its device is already busy processing another IRP.

StartIo routine, which the I/O manager calls to start I/O operations for IRPs the driver has queued to a system-supplied IRP queue (see IoStartPacket).

 

附IoStartPacket()原型(IRQL: <= DISPATCH_LEVEL )

VOID 
  IoStartPacket(
    IN PDEVICE_OBJECT  DeviceObject,
    IN PIRP  Irp,
    IN PULONG  Key  OPTIONAL,
    IN PDRIVER_CANCEL  CancelFunction  OPTIONAL
    );


 

posted @ 2011-09-16 16:31  onemuji  阅读(252)  评论(0编辑  收藏  举报