[concurrency-interest] The very best CAS loop
aph at redhat.com
Sun Sep 25 03:02:55 EDT 2016
On 25/09/16 07:45, Romain Colle wrote:
> Out of curiosity, why are we using a weak CAS instead of a regular one in this method?
It's an efficiency concern. On machines which support weak CAS, a CAS
can fail because of contention (or a spurious wakeup; these can happen
for any reason) or because the variable actually changed. On such
machines, a strong CAS is usually implemented as a loop which spins.
In that case it makes more sense to fetch the variable again and retry
All of this is perhaps easier to see with an assembly-language
example, which I can provide on request. :-)
More information about the Concurrency-interest