Lock-Free Data Structures in C++ Compare and Swap Routine -
in paper: lock-free data structures (pdf) following "compare , swap" fundamental shown:
template <class t> bool cas(t* addr, t exp, t val) { if (*addr == exp) { *addr = val; return true; } return false; }
and says
the entire procedure atomic
but how so? not possible other actor change value of addr
between if
, assignment? in case, assuming code using cas fundamental, found next time "expected" way, , wasn't. however, doesn't change fact happen, in case, still atomic? other actor returning true, when it's changes overwritten actor? if can't possibly happen, why?
i want believe author, missing here? thinking must obvious. apologies in advance if seems trivial.
he describing atomic operation given implementation, "somehow." pseudo-code implemented in hardware.
Comments
Post a Comment