Multiple ChoiceBeginner 45s
std::atomic<bool> vs volatile
Why is `volatile` not a substitute for `std::atomic` for inter-thread signaling?
Options
- 1volatile gives no atomicity or ordering across threads; it only prevents the compiler from optimizing the access away (meant for memory-mapped I/O/signals).
- 2volatile is fully atomic but simply slower than std::atomic, so it is a performance trade-off.
- 3They are equivalent on x86 and only differ in semantics when the code is ported to ARM.
- 4volatile provides release semantics only, while std::atomic additionally provides acquire.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.