Export (0) Print
Expand All
Expand Minimize

InterlockedExchangePointer function

Atomically exchanges a pair of addresses.

Syntax


PVOID __cdecl InterlockedExchangePointer(
  _Inout_  PVOID volatile *Target,
  _In_     PVOID Value
);

Parameters

Target [in, out]

A pointer to the address to exchange. The function sets the address pointed to by the Target parameter (*Target) to the address that is the value of the Value parameter, and returns the prior value of the Target parameter.

Value [in]

The address to be exchanged with the address pointed to by the Target parameter (*Target).

Return value

The function returns the initial address pointed to by the Target parameter.

Remarks

This function copies the address passed as the second parameter to the first and returns the original address of the first.

On a 64-bit system, the parameters are 64 bits and the Target parameter must be aligned on 64-bit boundaries; otherwise, the function will behave unpredictably. On a 32-bit system, the parameters are 32 bits and the Target parameter must be aligned on 32-bit boundaries.

The interlocked functions provide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. This function is atomic with respect to calls to other interlocked functions.

This function is implemented using a compiler intrinsic where possible. For more information, see the WinBase.h header file and _InterlockedExchangePointer.

This function generates a full memory barrier (or fence) to ensure that memory operations are completed in order.

Itanium-based systems:  For performance-critical applications, use InterlockedExchangePointerAcquire instead.

Note  This function is supported on Windows RT-based systems.

Note  

Requirements

Minimum supported client

Windows XP [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

WinBase.h (include Windows.h)

See also

Interlocked Variable Access
InterlockedCompareExchange
InterlockedExchange
InterlockedExchangeAcquire
InterlockedExchangeNoFence
InterlockedExchange8
InterlockedExchange16
InterlockedExchange16Acquire
InterlockedExchange16NoFence
InterlockedExchange64
InterlockedExchangeAcquire64
InterlockedExchangeNoFence64
InterlockedExchangePointerAcquire
InterlockedExchangePointerNoFence
InterlockedExchangeAdd
InterlockedExchangeSubtract
Synchronization Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft