[concurrency-interest] AtomicReference.updateAndGet() mandatory updating

Aleksey Shipilev shade at redhat.com
Tue May 30 14:56:45 EDT 2017

On 05/30/2017 08:23 PM, Hans Boehm wrote:
> C++ clearly specifies "CAS classic". There is no way to specify release
> semantics for a failed CAS, since there is no write.

To add to the snowball of confusion here, x86 seems to always do the write with
CAS, even on failure:

Intel SDM, Vol 2A, ISA Reference, "CMPXCHG — Compare and Exchange":

"This instruction can be used with a LOCK prefix to allow the instruction to be
executed atomically. To simplify the interface to the processor’s bus, the
destination operand receives a write cycle without regard to the result of the
comparison. The destination operand is written back if the comparison fails;
otherwise, the source operand is written into the destination. (The processor
never produces a locked read without also producing a locked write.)"

So in x86 work, there *is* a write, but that does not really help us, because it
writes the indistinguishably old value back...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20170530/fd46438d/attachment.sig>

More information about the Concurrency-interest mailing list