4 ms·
I think he's trying to get at what happens if an operation becomes non-atomic. In the case of the long long, there could be two register loads, rather than one.
by dbcfd 13y ago
I think he's trying to get at what happens if an operation becomes non-atomic. In the case of the long long, there could be two register loads, rather than one. Normally, you would expect calc(1) to return m1 at t0, or m1 at t1, dependent on when the change thread hits. However, if your operation requires two register loads (long long on 32), you would have a third value produced, which is neither m1 at t0 or m1 at t1.
This could be considered a non-thread safe operation.
- eatitraw 13y agoI understand the problem with non-atomicity, but it has nothing to do with thread-safety of calc(). Executing non-threadsafe function, and threadsafe function simultaneously is not a threadsafe operation. But the article says nothing about such situations, it places no restrictions on such situations. The thread-safe requirenment is for const-functions. I am probably not a good explainer, so here is the link: http://stackoverflow.com/questions/14127379/does-const-mean-thread-safe-in-c11 http://stackoverflow.com/questions/14127379/does-const-mean-...