SysCpuAtomicCompareAndSwap (FUN)

FUNCTION SysCpuAtomicCompareAndSwap : RTS_IEC_RESULT

<description> Function for compare-and-swap in one atomic operation (task safe). Supports only 32- and 64-bit types

The function compares the pAddress value with the pCompareValue value. If the pAddress value is equal to the pCompareValue value, the pSwapValue value is stored in the address specified by pAddress. Otherwise, no operation is performed.

The function was successful if the *pSwapValue value is stored in the address specified by pAddress. </description> <result><p>RESULT: Returns ERR_OK if the swap was successful (if the pSwapValue value is stored in the address specified by pAddress) </p></result> <SIL2/>

InOut:

Scope

Name

Type

Comment

Return

SysCpuAtomicCompareAndSwap

RTS_IEC_RESULT

Input

pAddress

POINTER TO BYTE

pointer to the value to test

pSwapValue

POINTER TO BYTE

pointer to new valid

pCompareValue

POINTER TO BYTE

pointer to compare value

valueSize

USINT

size of the value