KeAcquireSpinLock - NtDoc

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

void KeAcquireSpinLock(
  SpinLock,
  OldIrql
);

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-wdm-keacquirespinlock)

Description

The KeAcquireSpinLock routine acquires a spin lock so the caller can synchronize access to shared data in a multiprocessor-safe way by raising IRQL.

Parameters

SpinLock

Pointer to an initialized KSPIN_LOCK spin lock for which the caller provides the storage.

OldIrql

Pointer to a KIRQL variable that is set to the current IRQL when this call occurs.

Remarks

KeAcquireSpinLock first resets the IRQL to DISPATCH_LEVEL and then acquires the lock. The previous IRQL is written to OldIrql after the lock is acquired.

The OldIrql value must be specified when the spin lock is released with KeReleaseSpinLock.

Most drivers use a local variable to store the old IRQL value. A driver can also use a shared memory location, such as a global variable, but the driver must not use the same location for two different locks. Otherwise, a race condition can occur.

Spin locks can cause serious problems if not used judiciously. In particular, no deadlock protection is performed and dispatching is disabled while the spin lock is held. Therefore:

Attempting to acquire a spin lock recursively is guaranteed to cause a deadlock. For more information about spin locks, see Spin Locks.

See also

KeAcquireInStackQueuedSpinLock

KeAcquireSpinLockAtDpcLevel

KeInitializeSpinLock

KeReleaseSpinLock

Spin Locks