1.3.3 Spin Locks and Interlocks

IoAcquireCancelSpinLock 
Synchronizes cancelable-state transitions for IRPs in a multiprocessor-safe manner.
IoSetCancelRoutine 
Sets or clears the Cancel routine in an IRP during a cancelable state transition. Setting a Cancel routine makes an IRP cancelable.
IoReleaseCancelSpinLock 
Releases the cancel spin lock when the driver has changed the cancelable state of an IRP or releases the cancel spin lock from the driver’s Cancel routine.
KeInitializeSpinLock 
Initializes a variable of type KSPIN_LOCK, used to synchronize access to data shared among nonISR routines. An initialized spin lock also is a required parameter to the ExInterlockedXxx routines.
KeAcquireSpinLock 
Acquires a spin lock so the caller can synchronize access to shared data in a multiprocessor-safe way.
KeReleaseSpinLock 
Releases a spin lock that was acquired by calling KeAcquireSpinLock and restores the original IRQL at which the caller was running.
KeAcquireSpinLockAtDpcLevel 
Acquires a spin lock, provided that the caller is already running at IRQL DISPATCH_LEVEL.
KeReleaseSpinLockFromDpcLevel
Releases a spin lock that was acquired by calling KeAcquireSpinLockAtDpcLevel.
ExInterlocked..List
Insert and remove IRPs in a driver-managed internal queue, which is protected by an initialized spin lock for which the driver provides the storage.
ExInterlocked..Zone
Allocates and deallocates fixed-size entries, under spin lock control, from a driver-allocated and initialized zone buffer.
Ke..DeviceQueue
Insert and remove IRPs in a driver-allocated and managed internal device queue object, which is protected by a built-in spin lock.
ExInterlockedAddUlong 
Adds a value to a variable of type ULONG as an atomic operation, using a spin lock to ensure multiprocessor-safe access to the variable; returns the original (unsummed) value of the variable.
ExInterlockedAddLargeInteger 
Adds a value to a variable of type LARGE_INTEGER as an atomic operation, using a spin lock to ensure multiprocessor-safe access to the variable; returns the original (unsummed) value of the variable.
InterlockedIncrement 
Increments a variable of type LONG as an atomic operation. The sign of the return value is the sign of the result of the operation.
InterlockedDecrement 
Decrements a variable of type LONG as an atomic operation. The sign of the return value is the sign of the result of the operation.
InterlockedExchange 
Sets a variable of type LONG to a specified value as an atomic operation; returns the original (unset) value of the variable.
KeGetCurrentProcessorNumber 
Returns the current processor number when debugging spin lock usage in SMP machines.