Regarding the atomic_t interfaces, we should mention that all the following atomic_t constructs are for 32-bit integers only; of course, with 64-bit integers now being commonplace, 64-bit atomic integer operators are available as well. Typically, they are semantically identical to their 32-bit counterparts with the difference being in the name (atomic_foo() becomes atomic64_foo()). So the primary data type for 64-bit atomic integers is called atomic64_t (AKA atomic_long_t). The refcount_t interfaces, on the other hand, cater to both 32 and 64-bit integers.
The following table shows how to declare and initialize an atomic_t and refcount_t variable, side by side so that you can compare and contrast them:
(Older) atomic_t (32-bit only) | (Newer) refcount_t (both 32- and 64-bit) | |
Header file to include |
<linux/atomic.h> |
<linux/refcount.h> |
Declare and initialize a variable | static atomic_t gb... |