3.8 Device Queue Objects and Interlocked Queues
Except for NT file system drivers, the I/O Manager associates a device queue object with each device object that an NT driver creates, as already shown in Figure 3.2.
Most NT device drivers call the I/O Manager's support routines to use the associated device queue that holds IRPs whenever device I/O requests for a target device object come in faster than the driver can process them to completion. With this technique, IRPs are queued to a driver-supplied StartIo routine.
For good performance, most NT intermediate drivers simply pass IRPs on to lower drivers as fast as they come in, so intermediate drivers almost never use the device queues associated with their respective device objects.
However, NT driver writers can design their drivers to manage internal queues of IRPs by explicitly setting up one or more device queue objects or interlocked queues, particularly if the driver controls a device that overlaps I/O operations. For such a device, the driver designer might find it difficult to manage concurrent processing of two or more IRPs for the same target device object using only a single queue.
An NT driver designer also might decide to set up supplemental queues for IRPs in the driver of a device controller for a set of heterogeneous physical devices.
For example, the NT SCSI port driver uses device queue objects for internal queues, as already mentioned in Section 3.1. This driver both has a StartIo routine and sets up device queue objects as supplemental queues: that is, in addition to the device queue associated with the device object it creates to represent an HBA. The NT SCSI port driver uses its supplemental device queues to hold IRPs bound for particular logical units on the HBA-controlled SCSI bus(es).
The system floppy controller driver is an example of a driver that has no StartIo routine and uses an interlocked queue, as already mentioned in Chapter 2. This driver sets up a doubly linked interlocked queue into which and from which the driver and its device-dedicated thread insert and remove IRPs.
The NT Kernel defines the device queue object type. The Executive Support component provides routines for inserting and removing IRPs in interlocked queues. The next subsection explains how to set up and use a device queue object. Section 3.8.2 explains how to set up and use interlocked queues.
For more information about the I/O Manager's built-in support for IRP queueing in the device queue associated with a device object, see also Chapter 4.