The below sample code provides a sample implementation to the reader on different atomic operations that are available.
The following sample code merely provides a simple illustration of a few atomic bit operations. There are more atomic bit operations and the interested reader can look at “asm/bitops.h” for the specific architecture that he/she is working on (e.g. – x86/ARM etc).
The below Makefile can be used to compile the code.
save the above makefile as “Makefile” in the same directory as first_code.c and execute the “make” command on the terminal.
Kernel Locking mechanisms – spinlock
Pingback: Linux Kernel – atomic operations – sample code | Hitch Hiker's Guide to Learning