阅读背景:

并发性:c++ 11内存模型中的原子性和易失性

来源:互联网 

A global variable is shared across 2 concurrently running threads on 2 different cores. The threads writes to and read from the variables. For the atomic variable can one thread read a stale value? Each core might have a value of the shared variable in its cache and when one threads writes to its copy in a cache the other thread on a different core might read stale value from its own cache. Or the compiler does strong memory ordering to read the latest value from the other cache? The c++11 standard library has std::atomic support. How this is different from the volatile keyword? How volatile and atomic types will behave differently in the above scenario?A global variable is shared across 2 concurrent




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: