[jmm-dev] weakCompareAndSet memory semantics
David Holmes
david.holmes at oracle.com
Fri Apr 22 22:28:44 UTC 2016
On 23/04/2016 1:24 AM, Andrew Haley wrote:
> On 04/22/2016 02:52 PM, David M. Lloyd wrote:
>> I think it boils down to this: it's likely to be slightly faster in some
>> situations. If it's not there, someone is going to ask for it, because
>> they will want that slight bump, and it's in both C++ and C. It seems
>> trivial to implement. So why *not* have it?
>
> There's also the case where you have a highly-contended counter --
> think profiling -- and you want to increment it, you can't tolerate
> much of a delay. It's a disaster if that counter goes backwards but
> failing to increment it at a time of high contention is not so bad.
> So you try it once and continue.
Agreed - perfectly valid usecase for weakCAS, and weakCAS has a benefit
over CAS. But that is not the inner-loop re-fetch versus outer-loop
re-fetch that I was questioning from Aleksey's original email.
But you are right that we don't say anything about this in the docs so
not a concern.
Cheers,
David
> Andrew.
>
More information about the jmm-dev
mailing list