Contiki-NG
Loading...
Searching...
No Matches
Atomic operations

Macros

#define atomic_cas_uint8(t, o, n)   atomic_generic_cas_uint8((t),(o),(n))
 Atomic compare-and-swap (CAS) on a byte.
 

Functions

bool atomic_generic_cas_uint8 (uint8_t *target, uint8_t old_val, uint8_t new_val)
 Atomic compare-and-swap (CAS) on a byte (generic impl.)
 

Detailed Description

This library provides an API and generic implementation of atomic operations.

The structure of this library is more or less the same as sys/mutex. By default, atomic operations are implemented by disabling interrupts temporarily. Platforms can provide better implementation using platform-specific features.

Macro Definition Documentation

◆ atomic_cas_uint8

#define atomic_cas_uint8 ( t,
o,
n )   atomic_generic_cas_uint8((t),(o),(n))

Atomic compare-and-swap (CAS) on a byte.

This macro expands to atomic_generic_cas_uint8() or CPU-provided implementation. Platform-independent code should use this macro instead of atomic_generic_cas_uint8().

Definition at line 67 of file atomic.h.

Function Documentation

◆ atomic_generic_cas_uint8()

bool atomic_generic_cas_uint8 ( uint8_t * target,
uint8_t old_val,
uint8_t new_val )

Atomic compare-and-swap (CAS) on a byte (generic impl.)

Parameters
targetPointer to the target byte to manipulate.
old_valValue that is expected to be stored in the target.
new_valValue that it stores to the target.

If value of target is equal to old_val, store new_val to target. If the store operation succeeds, it returns true. Otherwise, it just returns false without storing.

Definition at line 42 of file atomic.c.

References critical_enter(), and critical_exit().