Argon RTOS  1.3.0
Tiny embedded real-time kernel
Atomic Operations
+ Collaboration diagram for Atomic Operations:

Description

Atomic operation functions.

Atomic operations

int8_t ar_atomic_add8 (volatile int8_t *value, int8_t delta)
 Atomic 8-bit add operation. More...
 
int16_t ar_atomic_add16 (volatile int16_t *value, int16_t delta)
 Atomic 16-bit add operation. More...
 
int32_t ar_atomic_add32 (volatile int32_t *value, int32_t delta)
 Atomic 32-bit add operation. More...
 
bool ar_atomic_cas8 (volatile int8_t *value, int8_t expectedValue, int8_t newValue)
 Atomic 8-bit compare and swap operation. More...
 
bool ar_atomic_cas16 (volatile int16_t *value, int16_t expectedValue, int16_t newValue)
 Atomic 16-bit compare and swap operation. More...
 
bool ar_atomic_cas32 (volatile int32_t *value, int32_t expectedValue, int32_t newValue)
 Atomic 32-bit compare and swap operation. More...
 

Function Documentation

◆ ar_atomic_add16()

int16_t ar_atomic_add16 ( volatile int16_t *  value,
int16_t  delta 
)

Atomic 16-bit add operation.

A memory barrier is performed prior to the add operation.

Parameters
valuePointer to the word to add to.
deltaSigned value to atomically add to *value.
Returns
The original value is returned.

◆ ar_atomic_add32()

int32_t ar_atomic_add32 ( volatile int32_t *  value,
int32_t  delta 
)

Atomic 32-bit add operation.

A memory barrier is performed prior to the add operation.

Parameters
valuePointer to the word to add to.
deltaSigned value to atomically add to *value.
Returns
The original value is returned.

◆ ar_atomic_add8()

int8_t ar_atomic_add8 ( volatile int8_t *  value,
int8_t  delta 
)

Atomic 8-bit add operation.

A memory barrier is performed prior to the add operation.

Parameters
valuePointer to the word to add to.
deltaSigned value to atomically add to *value.
Returns
The original value is returned.

◆ ar_atomic_cas16()

bool ar_atomic_cas16 ( volatile int16_t *  value,
int16_t  expectedValue,
int16_t  newValue 
)

Atomic 16-bit compare and swap operation.

Tests the word pointed to by value for equality with expectedValue. If they are equal, the word pointed to by value is set to newValue. If *value is not equal to expectedValue, then no change is made. The return value indicates whether the swap was performed. Of course, this entire operation is guaranteed to be atomic even on multiprocessor platforms.

A memory barrier is performed prior to the compare and swap operation.

Parameters
valuePointer to the word to compare and swap.
expectedValueValue to compare against.
newValueValue to value to swap in if *value is equal to expectedValue.
Return values
falseNo change was made to *value.
trueThe swap was performed, and *value is now equal to newValue.

◆ ar_atomic_cas32()

bool ar_atomic_cas32 ( volatile int32_t *  value,
int32_t  expectedValue,
int32_t  newValue 
)

Atomic 32-bit compare and swap operation.

Tests the word pointed to by value for equality with expectedValue. If they are equal, the word pointed to by value is set to newValue. If *value is not equal to expectedValue, then no change is made. The return value indicates whether the swap was performed. Of course, this entire operation is guaranteed to be atomic even on multiprocessor platforms.

A memory barrier is performed prior to the compare and swap operation.

Parameters
valuePointer to the word to compare and swap.
expectedValueValue to compare against.
newValueValue to value to swap in if *value is equal to expectedValue.
Return values
falseNo change was made to *value.
trueThe swap was performed, and *value is now equal to newValue.

◆ ar_atomic_cas8()

bool ar_atomic_cas8 ( volatile int8_t *  value,
int8_t  expectedValue,
int8_t  newValue 
)

Atomic 8-bit compare and swap operation.

Tests the word pointed to by value for equality with expectedValue. If they are equal, the word pointed to by value is set to newValue. If *value is not equal to expectedValue, then no change is made. The return value indicates whether the swap was performed. Of course, this entire operation is guaranteed to be atomic even on multiprocessor platforms.

A memory barrier is performed prior to the compare and swap operation.

Parameters
valuePointer to the word to compare and swap.
expectedValueValue to compare against.
newValueValue to value to swap in if *value is equal to expectedValue.
Return values
falseNo change was made to *value.
trueThe swap was performed, and *value is now equal to newValue.