Increments a single word variable atomically.
#include <sys/atomic_op.h>
int fetch_and_add ( word_addr, value)
atomic_p word_addr;
int value;
word_addr | Specifies the address of the word variable to be incremented. |
value | Specifies the value to be added to the word variable. |
The fetch_and_add kernel service atomically increments a single word. This operation is useful when a counter variable is shared between several kernel threads, since it ensures that the fetch, update, and store operations used to increment the counter occur atomically (are not interruptible).
The fetch_and_add kernel service can be called from either the process or interrupt environment.
The fetch_and_add kernel service returns the original value of the word.
The fetch_and_and kernel service, fetch_and_or kernel service, compare_and_swap kernel service.
Locking Kernel Services in AIX 5L Version 5.2 Kernel Extensions and Device Support Programming Concepts