InterlockedCompareExchange128

InterlockedCompareExchange128 performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 128-bit values and exchanges them with another 128-bit value based on the outcome of the comparison.

Syntax

Copy
LONGLONG InterlockedCompareExchange128(
        LONGLONG volatile *Destination,
        LONGLONG          ExchangeHigh,
        LONGLONG        ExchangeLow,
        LONGLONG          *ComparandResult
);

Parameters

Destination

A pointer to the destination value.

ExchangeHigh

The high-order part of the exchange value.

ExchangeLow

The low-order part of the exchange value.

ComparandResult

The value to compare to. This parameter is an array of two 64-bit integers considered as a 128-bit field.

Return Value

The function returns 1 if ComparandResult equals the original value of the Destination parameter, or 0 if ComparandResult does not equal the original value of the Destination parameter.

Remarks

The function compares the Destination value with the ComparandResult value:

If the Destination value is equal to the ComparandResult value, the ExchangeHigh and ExchangeLow values are stored in the array specified by Destination, and in the array specified by ComparandResult.

Otherwise, the ExchangeHigh and ExchangeLow values are only stored in the array specified by ComparandResult.

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. For more information, see the WinBase.h header file and _InterlockedCompareExchange128.

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

To operate on 16-bit values, use the InterlockedCompareExchange16 function.

To operate on 32-bit values, use the InterlockedCompareExchange function.

To operate on 64-bit values, use the InterlockedCompareExchange64 function.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

windows.h

rtkrnl.lib

See Also: