WdfSpinLockCreate - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// wdfsync.h

NTSTATUS WdfSpinLockCreate(
  [in, optional] PWDF_OBJECT_ATTRIBUTES SpinLockAttributes,
  [out]          WDFSPINLOCK            *SpinLock
);

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-wdfsync-wdfspinlockcreate)

WdfSpinLockCreate function

Description

[Applies to KMDF and UMDF]

The WdfSpinLockCreate method creates a framework spin-lock object.

Parameters

SpinLockAttributes [in, optional]

A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure that specifies attributes for the spin-lock object. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

SpinLock [out]

A pointer to a location that receives a handle to a new framework spin-lock object.

Return value

WdfSpinLockCreate returns STATUS_SUCCESS if the operation succeeds.

For a list of other return values that the WdfSpinLockCreate method might return, see Framework Object Creation Errors.

This method also might return other NTSTATUS values.

Remarks

The WdfSpinLockCreate method creates a framework spin-lock object. After creating a spin-lock object, a driver can call WdfSpinLockAcquire to acquire the lock and WdfSpinLockRelease to release the lock.

By default, the new spin-lock object's parent is the framework driver object that the WdfDriverCreate method created. You can use the ParentObject member of the WDF_OBJECT_ATTRIBUTES structure to specify a different parent. The framework deletes the spin-lock object when it deletes the parent object. If your driver does not change the default parent, the driver should delete the spin-lock object when it has finished using the object; otherwise, the object will remain until the I/O manager unloads your driver.

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

Examples

The following code example initializes a WDF_OBJECT_ATTRIBUTES, specifies that the spin lock's parent object will be a device object, and calls WdfSpinLockCreate.

WDF_OBJECT_ATTRIBUTES attributes;
WDFSPINLOCK lockHandle;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = Device;
status = WdfSpinLockCreate(
                           &attributes,
                           &lockHandle
                           );

See also

WDF_OBJECT_ATTRIBUTES

WdfDriverCreate

WdfSpinLockAcquire

WdfSpinLockRelease

WdfSpinlock rule (KMDF)

WdfSpinLockRelease rule (KMDF)