Handling Overlapped I/O Operations

The DpcForIsr or CustomDpc routine of a driver that overlaps operations on its device cannot rely on a one-to-one correspondence between requests input to the StartIo routine and the ISR's calls to IoRequestDpc or KeInsertQueueDpc. Such a driver's DpcForIsr or CustomDpc cannot necessarily use the input pointers to the IRP and ISR-supplied context, or the CurrentIrp pointer in the target device object, to complete only that IRP.

At any given moment, the same DPC object cannot be queued twice. If an ISR calls IoRequestDpc or KeInsertQueueDpc more than once before the corresponding DpcForIsr or CustomDpc executes, the DPC routine runs only once when the IRQL on a processor falls below DISPATCH_LEVEL. On the other hand, if the ISR calls IoRequestDpc or KeInsertQueueDpc while the corresponding DpcForIsr or CustomDpc is running on another processor, the DPC routine can run on two processors concurrently.

Therefore, any driver that overlaps interrupt-driven I/O operations on its device must have the following:

  • A DpcForIsr or CustomDpc routine that can complete some driver-maintained count of outstanding requests each time it is called

  • An ISR that never overwrites the context information that it passes to a DpcForIsr or CustomDpc routine, until that routine has used the context information and completed the IRP to which the context information belongs

  • A SynchCritSection routine that accesses the ISR's context area on behalf of the DpcForIsr or CustomDpc routine

 

 

Send comments about this topic to Microsoft

Show: