[cpp-threads] Failed compare-and-swap

Paul E. McKenney paulmck at linux.vnet.ibm.com
Mon Jul 30 23:07:59 BST 2007


On Tue, Jul 31, 2007 at 12:43:48AM +0300, Peter Dimov wrote:
> Paul E. McKenney wrote:
> 
> >There are algorithms in which a failed CAS plays a role similar to a
> >failed trylock.  So it would make quite a bit of sense for a failed
> >CAS to have the same memory-ordering semantics that it would have had
> >if successful.  After all, the common case should be successful CAS!
> >;-)
> 
> A failed trylock also (arguably) has (should have) no memory 
> synchronization properties. 

I would argue for trylock having the same ordering semantics that it
would have if successful, but there are a lot of implementations out
there that argue otherwise, and I doubt that I will be able to argue
them away -- though perhaps we should specify ordering in the standard.
With CAS, the programmer can choose the desired semantics, so there
should not be a problem.

						Thanx, Paul



More information about the cpp-threads mailing list