:::{note} AI Translation Notice
This document was automatically translated by Qwen/Qwen3-8B
model, for reference only.
Source document: kernel/core_api/atomic.md
Translation time: 2025-05-19 01:41:25
Translation model: Qwen/Qwen3-8B
Please report issues via Community Channel
:::
DragonOS implements atomic variables of type atomic_t
. Atomic variables are implemented using architecture-specific atomic operation instructions. The specific implementation is located in kernel/common/atomic.h
.
Note that all the following APIs are atomic operations.
inline void atomic_add(atomic_t *ato, long val)
Atomically adds a specified value to the atomic variable.
ato
The atomic variable object.
val
The value to be added to the variable.
inline void atomic_sub(atomic_t *ato, long val)
Atomically subtracts a specified value from the atomic variable.
ato
The atomic variable object.
val
The value to be subtracted from the variable.
void atomic_inc(atomic_t *ato)
Atomically increments the atomic variable by 1.
ato
The atomic variable object.
void atomic_dec(atomic_t *ato)
Atomically decrements the atomic variable by 1.
ato
The atomic variable object.
inline void atomic_set_mask(atomic_t *ato, long mask)
Performs a bitwise OR operation between the atomic variable and the mask variable.
ato
The atomic variable object.
mask
The variable used for the OR operation with the atomic variable.
inline void atomic_clear_mask(atomic_t *ato, long mask)
Performs a bitwise AND operation between the atomic variable and the mask variable.
ato
The atomic variable object.
mask
The variable used for the AND operation with the atomic variable.