INtime SDK Help
InterlockedCompareExchange (iwin32)
INtime SDK v7 > About INtime > Alternate APIs > iwin32 API > iwin32 API > InterlockedCompareExchange (iwin32)

Atomically compares the Destination and Comperand values. If the Destination value equals the Comperand value, the Exchange value is stored in the address specified by Destination. Otherwise, no action occurs.

LONG InterlockedCompareExchange( 
    LPLONG volatile Destination,
    LONG Exchange,
    LONG Comperand
);

Parameters

Destination
Destination value address.
Exchange
Exchange value.
Comperand
The value to compare to Destination.

Remarks

InterlockedCompareExchange, InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, and InterlockedIncrement provide a simple mechanism for synchronizing access to a variable shared by multiple threads. If the variable is in shared memory, threads of different processes can use this mechanism.

The variables for InterlockedCompareExchange must be aligned on a 32-bit boundary.

Return Values

The destination's initial value.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/winbase.h windows.h iwin32.lib

Note

This function operates in the real-time portion of your application.

See Also

InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, InterlockedIncrement, iwin32 API, iwin32 Overview