↧
Answer by BeeOnRope for Why does using the same cache-line from multiple...
What you are seeing is basically the effect of the store buffer combined with store-to-load forwarding allowing each core to work mostly independently, despite sharing a cache line. As we will see...
View ArticleAnswer by mksteve for Why does using the same cache-line from multiple...
The atomic version has to ensure that some other thread will be able to read the result in a sequentially consistent fashion. So there are fences for each write.The volatile version does not make any...
View ArticleWhy does using the same cache-line from multiple threads not cause serious...
Look at this snippet:#include <atomic>#include <thread>typedef volatile unsigned char Type;// typedef std::atomic_uchar Type;void fn(Type *p) { for (int i=0; i<500000000; i++) { (*p)++;...
View Article