Bewerken

Delen via


WdfSpinLockCreate function (wdfsync.h)

[Applies to KMDF and UMDF]

The WdfSpinLockCreate method creates a framework spin-lock object.

Syntax

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

Parameters

[in, optional] SpinLockAttributes

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.

[out] SpinLock

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
                           );

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfsync.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL <=DISPATCH_LEVEL
DDI compliance rules DriverCreate(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), ParentObjectCheckLock(kmdf), WdfSpinlock(kmdf)

See also

WDF_OBJECT_ATTRIBUTES

WdfDriverCreate

WdfSpinLockAcquire

WdfSpinLockRelease

WdfSpinlock rule (KMDF)

WdfSpinLockRelease rule (KMDF)