InterlockedExchangePointer function

The InterlockedExchangePointer routine performs an atomic operation that sets a pointer to a new value.

Syntax

PVOID InterlockedExchangePointer(
  _Interlocked_operand_ PVOID *Target,
  PVOID                       Value
);

Parameters

Target

A pointer to a PVOID value. The routine sets (*Target) to Value.

Value

Specifies the PVOID value to set (*Target) to.

Return Value

InterlockedExchangePointer returns the original value of the pointer at *Target (that is, the value of this pointer at entry to the routine).

Remarks

InterlockedExchangePointer provides a fast, atomic way to synchronize updating a pointer variable that is shared by multiple threads.

InterlockedExchangePointer is designed for speed and, typically, is implemented inline by a compiler. InterlockedExchangePointer is atomic only with respect to other InterlockedXxx calls. It does not use a spin lock and can be safely used on pageable data.

The Target parameter should be aligned on either a 32-bit or 64-bit boundary, depending on the system type, for better performance.

A call to InterlockedExchangePointer is atomic only with respect to other InterlockedXxx calls.

Interlocked operations cannot be used on non-cached memory.

Requirements

   
Windows version Available starting with Windows 2000.
Target Platform Desktop
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h, Miniport.h)
IRQL Any level

See Also

InterlockedCompareExchange

InterlockedCompareExchangePointer

InterlockedExchange