[concurrency-interest] Semantics of compareAndSwapX

Andrew Haley aph at redhat.com
Fri Feb 21 04:38:12 EST 2014


On 02/20/2014 04:40 PM, Andrew Dinn wrote:
> 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.

Me either, but I'm trying to find out what the specification
actually means when it says "atomic".

> 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?

That sounds plausible.

Andrew.



More information about the Concurrency-interest mailing list