IO_CSQ_RELEASE_LOCK callback function (wdm.h)
The CsqReleaseLock routine is used by the system to release the lock that was acquired using CsqAcquireLock.
Syntax
IO_CSQ_RELEASE_LOCK IoCsqReleaseLock;
void IoCsqReleaseLock(
[in] PIO_CSQ Csq,
[in] KIRQL Irql
)
{...}
Parameters
[in] Csq
Pointer to the IO_CSQ structure for the cancel-safe IRP queue.
[in] Irql
Specifies an IRQL. This is the value stored by CsqAcquireLock when the lock was acquired.
Return value
None
Remarks
The driver specifies the CsqReleaseLock routine for a cancel-safe IRP queue when it initializes the queue's IO_CSQ structure. The driver specifies the routine as the CsqReleaseLock parameter of IoCsqInitialize or IoCsqInitializeEx when it initializes IO_CSQ. For more information, see Cancel-Safe IRP Queues.
The system calls this function to release a lock that was acquired using CsqAcquireLock.
If the driver uses a spin lock to implement locking for the queue, it must store the current IRQL when it acquires the lock, and provide the stored IRQL when it releases the lock. The CsqAcquireLock routine stores the current IRQL, and the system passes the stored value as the Irql parameter to CsqReleaseLock. Otherwise the driver can ignore the Irql parameter. For information about spin locks, see Spin Locks.
Drivers can use any locking mechanism to lock the queue, such as mutexes. For more information about mutexes, see Mutex Objects.
Examples
To define a CsqReleaseLock callback routine, you must first provide a function declaration that identifies the type of callback routine you're defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it's a requirement for writing drivers for the Windows operating system.
For example, to define a CsqReleaseLock callback routine that is named MyCsqReleaseLock
, use the IO_CSQ_RELEASE_LOCK type as shown in this code example:
IO_CSQ_RELEASE_LOCK MyCsqReleaseLock;
Then, implement your callback routine as follows:
_Use_decl_annotations_
VOID
MyCsqReleaseLock(
PIO_CSQ Csq,
KIRQL Irql
)
{
// Function body
}
The IO_CSQ_RELEASE_LOCK function type is defined in the Wdm.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the _Use_decl_annotations_
annotation to your function definition. The _Use_decl_annotations_
annotation ensures that the annotations that are applied to the IO_CSQ_RELEASE_LOCK function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for WDM Drivers. For information about _Use_decl_annotations_
, see Annotating Function Behavior.
Requirements
Requirement | Value |
---|---|
Target Platform | Desktop |
Header | wdm.h (include Wdm.h, Ntddk.h, Ntifs.h) |