[concurrency-interest] Semantics of compareAndSwapX
adinn at redhat.com
Thu Feb 20 11:40:22 EST 2014
On 20/02/14 15:35, Andrew Haley wrote:
> On 02/20/2014 10:25 AM, David Holmes wrote:
>> The volatile-read followed by volatile-write implicit in the CAS precludes
>> any accesses before the cas appearing after, or vice-versa. I would appeal
>> intuitively to "roach motel" semantics but Aleksey would jump on me. ;-)
> True enough, but that does not preclude, say, a write access to am
> unrelated location appearing after the volatile read but before the
> volatile write. Does that matter? I guess it must not, but it does
> mean that the CAS may not be strictly atomic.
I cannot really see why that should be an issue except for broken code.
If the validity of changing some other location is dependent upon there
being an intermediate state of the thing being modified by the CAS for
some interval between the load acquire and store release then surely
that just means there is already a race?
More information about the Concurrency-interest