InterlockedCompareExchangeRelease routine

The InterlockedCompareExchangeRelease routine uses release semantics to atomically update the value of a variable if that variable is equal to a specified value.

Syntax


LONG InterlockedCompareExchangeRelease(
  _Inout_ LONG volatile *Destination,
  _In_    LONG          Exchange,
  _In_    LONG          Comparand
);

Parameters

Destination [in, out]

A pointer to the variable to compare with Comparand. If the variable is equal to Comparand, the variable receives the value of Exchange; otherwise, the variable remains unchanged.

Exchange [in]

Specifies the value that *Destination receives if *Destination = Comparand.

Comparand [in]

Specifies the value to compare to *Destination.

Return value

InterlockedCompareExchangeRelease returns the original value of *Destination.

Remarks

The InterlockedCompareExchangeRelease routine performs the same operation as InterlockedCompareExchange, except that the former guarantees only release semantics whereas the latter guarantees both acquire and release semantics. For more information about acquire and release semantics, see Acquire and Release Semantics.

On processors that do not support release-semantics operations, InterlockedCompareExchangeRelease is identical to InterlockedCompareExchange. On processors such as Intel Itanium-based processors, which do support these operations, InterlockedCompareExchangeRelease runs faster.

Interlocked operations cannot be used on non-cached memory.

Requirements

Target platform

Version

Available only on Windows Server 2003 and later versions of the Windows operating system.

Header

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

IRQL

Any level

See also

InterlockedCompareExchange
InterlockedCompareExchangeRelease

 

 

Send comments about this topic to Microsoft

Show: