KeInitializeSpinLock function

The KeInitializeSpinLock routine initializes a variable of type KSPIN_LOCK.

Syntax

void KeInitializeSpinLock(
  PKSPIN_LOCK SpinLock
);

Parameters

SpinLock

Pointer to a spin lock, for which the caller must provide the storage.

Return Value

None

Remarks

This routine must be called before an initial call to KeAcquireSpinLock, to KeAcquireInStackQueuedSpinLock, or to any other support routine that requires a spin lock as an argument.

Storage for a spin lock object must be resident: in the device extension of a driver-created device object, in the controller extension of a driver-created controller object, or in nonpaged pool allocated by the caller.

Note

This function is inlined for x64 systems from Windows XP till Windows 7. Starting in Windows 8, this function is exported from ntoskrnl.lib. As a result, if you are using the Windows 10 WDK to build a binary that runs on Windows 7 (and therefore you need NX pool usage to pass Windows 10 HLK tests), you must define WIN9X_COMPAT_SPINLOCK. Otherwise, you may see Windows cannot load the device driver for this hardware. The driver may be corrupted or missing. (Code 39).

For more information about spin locks, see Spin Locks.

Callers of this routine can be running at any IRQL. Usually, a caller is running at IRQL = PASSIVE_LEVEL in an AddDevice routine.

Requirements

   
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL Any level (see Remarks section)
DDI compliance rules HwStorPortProhibitedDDIs

See Also

KeAcquireInStackQueuedSpinLock

KeAcquireInStackQueuedSpinLockAtDpcLevel

KeAcquireSpinLock

KeAcquireSpinLockAtDpcLevel

KeReleaseInStackQueuedSpinLock

KeReleaseInStackQueuedSpinLockFromDpcLevel

KeReleaseSpinLock

KeReleaseSpinLockFromDpcLevel