[cpp-threads] Failed compare-and-swap

Hans Boehm Hans.Boehm at hp.com
Wed Aug 1 06:23:38 BST 2007


I think there's some confusion here.  If we really had no ordering 
semantics for failed CAS operations, even for ostensibly SC ones,
we wouldn't get SC semantics for data-race-free programs.  Is that
really what Bill is advocating?

Hans

On Tue, 31 Jul 2007, Herb Sutter wrote:

> Bill wrote:
>> I cast my vote for saying that a failed compare and swap or failed
>> trylock should have no synchronization semantics.
>>
>> The only idioms I know of that would depend on failed atomic
>> operations having synchronization semantics are so problematical that
>> we should do everything we can to discourage people from trying to
>> use them.
>
> Do you feel that "using a CAS as an atomic load" is a problematic idiom and should be not just discouraged but outlawed? (I'm actually open to that option, I'm just trying to state it as strongly as it probably should be stated, because if we don't require the synchronization semantics on failure then we really do outlaw it in portable code.)
>
>> By giving fail operations semantics, you also rule out possible
>> implementation strategies that might be advantageous in some current
>> or future platform.
>
>
> -- 
> cpp-threads mailing list
> cpp-threads at decadentplace.org.uk
> http://www.decadentplace.org.uk/cgi-bin/mailman/listinfo/cpp-threads
>



More information about the cpp-threads mailing list