Nine ways to break your systems code using volatile

Volatile qualifier is a tool in C/C++ that can be easily misused but can be effective in a specific set of circumstances. This article explains the history of volatile and provides examples of how not to use it, while also highlighting how to use it effectively to create correct systems software. The C program is defined in terms of an “abstract machine,” and the behavior of the actual machine may be different from the abstract machine. Volatile allows for communication between the abstract and actual machines, ensuring certain operations are performed at the level of actual computation. However, using volatile incorrectly or excessively can lead to confusion, bugs, and inefficiency. It’s important to use volatile only when there is a precise technical justification.

https://blog.regehr.org/archives/28

To top