|
VMS Help CC, Language topics, Builtin Functions, InterlockedCompareExchange acq *Conan The Librarian |
Atomically compares and exchanges the value specified by the first
argument (a 64-bit pointer). This function maps to the
cmpxchg4.acq instruction with appropriate setup.
The value at *Destination is compared with the value specified by
Comparand. If they are equal, Newval is written to *Destination,
and Oldval is returned. The exchange will have taken place if the
value returned is equal to the Comparand. The following algorithm
is used:
ar.ccv = Comparand;
Oldval = *Destination; //Atomic
if (ar.ccv == *Destination) //Atomic
*Destination = Newval; //Atomic
return Oldval;
Those parts of the algorithm marked "Atomic" are performed
atomically by the cmpxchg4.acq instruction. This instruction has
acquire ordering semantics; that is, the memory read/write is made
visible prior to all subsequent data memory accesses of the
Destination by other processors.
Syntax:
unsigned __int64 _InterlockedCompareExchange_acq (volatile
unsigned int *Destination, unsigned __int64 Newval, unsigned
__int64 Comparand);
|
|