3 ms·
Why the "volatile" type class should not be used
- cratermoon 3y agoShould not be used in linux kernel code, that is. The way I learned volatile was that it's used to tell the compiler not to optimize away a variable that appears to not change. If, for example, there's a variable that can be set via an interrupt, outside the local flow of execution. A compiler might cache the value on first read, volatile ensures the variable is read freshly from memory every time. That does not ensure against unwanted concurrent access, so it's not it a synchronization mechanism.