Expand Minimize

InterlockedExchangePointer routine

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

Syntax


PVOID InterlockedExchangePointer(
  _Inout_   PVOID volatile *Target,
  _In_opt_  PVOID Value
);

Parameters

Target [in, out]

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

Value [in, optional]

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

Version

Available starting with Windows 2000.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

IRQL

Any level

See also

InterlockedCompareExchange
InterlockedCompareExchangePointer
InterlockedExchange

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft