KeInsertByKeyDeviceQueue

BOOLEAN
KeInsertByKeyDeviceQueue(

IN PKDEVICE_QUEUE DeviceQueue,
IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry,
IN ULONG SortKey
);

KeInsertByKeyDeviceQueue acquires the spin lock for the given DeviceQueue and queues an entry according to the given sort-key value if the state of the device queue is Busy.

Parameters

DeviceQueue

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

DeviceQueueEntry

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

SortKey

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.

Comments

The given device queue spin lock is acquired and the state of the device queue is checked. If the state of the device queue is Busy, 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 state transition from Not-Busy to Busy.

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

Callers of KeInsertByKeyDeviceQueue must be running at IRQL DISPATCH_LEVEL.

See Also

KeInitializeDeviceQueue, KeInsertDeviceQueue, KeRemoveDeviceQueue, KeRemoveEntryDeviceQueue