WdfObjectAcquireLock method

[Applies to KMDF and UMDF]

The WdfObjectAcquireLock method acquires an object's synchronization lock.

Syntax


VOID WdfObjectAcquireLock(
  [in]  WDFOBJECT Object
);

Parameters

Object [in]

A handle to a framework device object or a framework queue object.

Return value

None.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

A driver can call the WdfObjectAcquireLock method to acquire the synchronization lock that is associated with a specified framework device object or framework queue object. The method does not return until the lock has been acquired.

When the driver no longer needs the object's synchronization lock, it must call WdfObjectReleaseLock.

If the driver specified WdfExecutionLevelPassive for the ExecutionLevel member of the specified object's WDF_OBJECT_ATTRIBUTES structure, the driver must call WdfObjectAcquireLock at IRQL <= APC_LEVEL. WdfObjectAcquireLock acquires a fast mutex and returns at the caller's IRQL. (In this case, WdfObjectAcquireLock also calls KeEnterCriticalRegion before returning so that normal kernel APCs are disabled.)

If the driver did not specify WdfExecutionLevelPassive for the ExecutionLevel member of the specified object's WDF_OBJECT_ATTRIBUTES structure, the driver must call WdfObjectAcquireLock at IRQL <= DISPATCH_LEVEL. WdfObjectAcquireLock acquires a spin lock and returns at IRQL = DISPATCH_LEVEL.

For more information about synchronization locks, see Synchronization Techniques for Framework-Based Drivers.

Examples

The following code example acquires an object's synchronization lock. The driver previously obtained the object handle by calling WdfDeviceCreate or WdfIoQueueCreate.


WdfObjectAcquireLock(Object);

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfsync.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

See Remarks section.

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

KeEnterCriticalRegion
WDF_OBJECT_ATTRIBUTES
WdfObjectReleaseLock

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft