KeAcquireSpinLock

VOID
KeAcquireSpinLock(

IN PKSPIN_LOCK SpinLock,
OUT PKIRQL OldIrql
);

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

Parameters

SpinLock

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

OldIrql

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

Comments

The current IRQL is saved in OldIrql. Then, the current IRQL is reset to DISPATCH_LEVEL, and the specified spin lock is acquired.

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

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:

·The code within a critical region guarded by an spin lock must neither be pageable nor make any references to pageable data.

·The code within a critical region guarded by a spin lock can neither call any external function that might access pageable data or raise an exception, nor can it generate any exceptions.

·The caller should release the spin lock with KeReleaseSpinLock as quickly as possible.

Callers of KeAcquireSpinLock must be running at IRQL <= DISPATCH_LEVEL.

See Also

KeAcquireSpinLockAtDpcLevel, KeInitializeSpinLock, KeReleaseSpinLock