8.3 ISR Functionality for Overlapped I/O Operations

While the ISR and DpcForIsr (or CustomDpc) can run concurrently in Windows NT SMP machines, only one instantiation of the DPC object that represents a DpcForIsr or CustomDpc routine can be queued for execution at any given moment.

If the same DPC object is queued more than once by an ISR before the DpcForIsr (or CustomDpc) routine is run, the corresponding DpcForIsr or CustomDpc routine is called only once. If the DPC object is queued while the DpcForIsr (or CustomDpc) is running, two instantiations of this routine can run concurrently in Windows NT SMP machines.

Consequently, any NT driver that overlaps I/O operations on its device(s) must have DpcForIsr and/or CustomDpc routines that can complete more than one IRP when they are called. Such a driver’s ISR has the same basic requirements as a device driver that does not overlap I/O operations, as already described in Section 8.2.

However, such a device driver’s ISR must set up additional state for the DpcForIsr and/or CustomDpc routines, such as a count of how many outstanding requests the DPC routine is required to complete and whatever context the DPC routine needs to complete each outstanding IRP. Note that such a driver’s ISR must take care not to overwrite the saved context for a request that has not yet been completed if the ISR is called to handle another interrupt before the DPC is run.

Because such a driver’s DPC routine(s) would share this state with the ISR, its DPC routine(s) must call KeSynchronizeExecution with a driver-supplied SynchCritSection routine to access the shared state on behalf of each DPC routine.

For more information about DpcForIsr and CustomDpc routines, see Chapter 9. For more information about SynchCritSection routines and about the interaction of the ISR and DPCs queued from the ISR, see also Chapters 10 and 16, respectively.