Sep 20, 2015

[C++11] compare_exchange_weak and compare_exchange_strong

Understanding std::atomic::compare_exchange_weak() in C++11

cppreference for std::atomic::compare_exchange_strong

Load-link/store-conditional


Real implementations of LL/SC do not always succeed if there are no concurrent updates to the memory location in question.

Any exceptional events between the two operations, such as

a context switch,
another load-link,
or even (on many platforms) another load or store operation,

will cause the store-conditional to spuriously fail.

Older implementations will fail if there are any updates broadcast over the memory bus. This is often called weak LL/SC by researchers, as it breaks many theoretical LL/SC algorithms.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.