Expand Minimize

InterlockedCompareExchangeAcquire routine

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

Syntax


LONG InterlockedCompareExchangeAcquire(
  _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

InterlockedCompareExchangeAcquire returns the original value of *Destination.

Remarks

The InterlockedCompareExchangeAcquire routine performs the same operation as InterlockedCompareExchange, except that the former guarantees only acquire 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 acquire-semantics operations, InterlockedCompareExchangeAcquire is identical to InterlockedCompareExchange. On processors such as Intel Itanium-based processors, which do support these operations, InterlockedCompareExchangeAcquire runs faster.

Interlocked operations cannot be used on non-cached memory.

Requirements

Target platform

Desktop

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:
© 2015 Microsoft