Section: Kernel Functions (9)
atomic_add, atomic_sub, atomic_inc, atomic_dec - thread/SMP safe arithmetic on atomic data
void atomic_add(int i, volatile atomic_t*v)
void atomic_sub(int i, volatile atomic_t*v)
void atomic_inc(volatile atomic_t*v)
void atomic_dec(volatile atomic_t*v)
int atomic_read(volatile atomic_t*v)
void atomic_set(volatile atomic_t*v, int i)
int atomic_dec_and_test(volatile atomic_t*v)
These functions manipulate variables of type
is SMP and interrupt safe ways. These variables can be used to hold
spin locks or SMP-safe reference counters. These functions guarantee
that the operation that they represent is performed correctly. If
necessary, hardware bus locking is performed to protect the operation.
Usually, the CPU has some sort of atomic instructions that allow these
operations to be performed quickly and safely.
decrements the atomic variable, and returns true if the result is
zero. This function is particularly useful in implementing spin locks
on SMP systems.
function returns the integer value of the atomic variable.
returns TRUE if the value becomes zero after the decrement.
Stephen Williams <firstname.lastname@example.org>
The read and set operations generally have no special protections.