[cpp-threads] modes, pass 2

Peter Dimov pdimov at mmltd.net
Sun May 8 19:25:58 BST 2005


Ben Hutchings wrote:
> Peter Dimov wrote:
>> Doug Lea wrote:
>>>> I don't understand fallible_*,
>>>
>>> It means that CAS can return false just because it feels like it.
>>> Like LL/SC does on all platforms I know that use it.
>>
>> If an implementation gives me fallible CAS when I ask for infallible
>> CAS, how can I tell? And even if I could tell, why would I want to?
>
> If normal CAS fails you know that the value it read was not the
> expected value.  In this case you might not want to retry.  If
> "fallible CAS" based on LL/SC fails, you don't know that.

I think I get it now.

Infallible CAS: do { if( LL() != old ) return false; } while( !SC(new) ); 
return true;
Fallible CAS: return LL() == old && SC(new); 





More information about the cpp-threads mailing list