Export (0) Print
Expand All
Expand Minimize

KeInsertByKeyDeviceQueue routine

The KeInsertByKeyDeviceQueue routine acquires the spin lock for the specified DeviceQueue and queues an entry according to the specified sort-key value if the device queue is set to a busy state.


BOOLEAN KeInsertByKeyDeviceQueue(
  _Inout_  PKDEVICE_QUEUE DeviceQueue,
  _Inout_  PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
  _In_     ULONG SortKey


DeviceQueue [in, out]

Pointer to a control object of the device queue type for which the caller provides the storage.

DeviceQueueEntry [in, out]

Pointer to the device queue entry to be inserted into the device queue according to the specific key value.

SortKey [in]

Specifies the sort-key value that determines the position in the device queue in which to insert the entry.

Return value

If the device queue is empty, FALSE is returned, meaning the DeviceQueueEntry is not inserted in the device queue.


The specified device queue spin lock is acquired and the state of the device queue is checked. If the device queue is set to a busy state, the IRP specified by the DeviceQueueEntry is inserted into the device queue according to its sort key value and the device queue spin lock is released.

The new entry is positioned in the device queue after any entries in the queue with sort key values less than or equal to its sort key value and preceding any entries with sort key values that are greater.

If KeInsertByKeyDeviceQueue returns FALSE, the caller must begin processing the IRP. A call to KeInsertDeviceQueue or KeInsertByKeyDeviceQueue when the queue is empty causes the device queue to transition from a not-busy state to a busy state.

This routine is for code that queues an I/O request to a device driver.



Available starting with Windows 2000.


Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)





DDI compliance rules

IrqlDispatch, MarkingQueuedIrps, HwStorPortProhibitedDDIs, IrqlDispatch(storport)

See also




Send comments about this topic to Microsoft

© 2014 Microsoft