Quantcast
Channel: atomic writes and volatile reads - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by David Schwartz for atomic writes and volatile reads

On all platforms that you are likely to use that support C++ and multiple threads, reading from a volatile-qualified, aligned int will be atomic and will read the latest value. However, it is...

View Article



Answer by Constantin Baranov for atomic writes and volatile reads

volatile doesn't make read operations atomic. Non-atomic reads concurrent with (atomic) write lead to an undefined behavior. Use atomic read in any form, either std::atomic or intrinsics. Don't use...

View Article

Answer by Turn for atomic writes and volatile reads

The volatile keyword only ensures that compiler will not store the variable in a register and instead will load the variable from memory every time it is used. It has nothing to do with the cache or...

View Article

atomic writes and volatile reads

I am designing an multi threaded algorithm in which the requirement is to read the latest value of a shared variable. The writes to the variable are atomic (using compare-and-swap). However, the reads...

View Article
Browsing all 4 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>