Answer by R.. GitHub STOP HELPING ICE for Is volatile a proper way to make a...
On any sane cpu, reading and writing any aligned, word-size-or-smaller type is atomic. This is not the issue. The issues are:Just because reads and writes are atomic, it does not follow that...
View ArticleAnswer by doron for Is volatile a proper way to make a single byte atomic in...
Short answer : Don't use volatile to guarantee atomicity.Long answerOne might think that since CPUs handle words in a single instruction, simple word operations are inherently thread safe. The idea of...
View ArticleAnswer by Thomas Matthews for Is volatile a proper way to make a single byte...
The volatile keyword is used to indicate that a variable (int, char, or otherwise) may be given a value from an external, unpredictable source. This usually deters the compiler from optimizing out the...
View ArticleAnswer by Omnifarious for Is volatile a proper way to make a single byte...
Not only does the standard not say anything about atomicity, but you are likely even asking the wrong question.CPUs typically read and write single bytes atomically. The problem comes because when you...
View ArticleAnswer by Oliver Charlesworth for Is volatile a proper way to make a single...
The standard says nothing about atomicity.
View ArticleIs volatile a proper way to make a single byte atomic in C/C++?
I know that volatile does not enforce atomicity on int for example, but does it if you access a single byte? The semantics require that writes and reads are always from memory if I remember...
View Article