[cpp-threads] Failed compare-and-swap

Boehm, Hans hans.boehm at hp.com
Wed Aug 1 21:24:48 BST 2007


> From:  Peter Dimov
> 
> Boehm, Hans wrote:
> 
> >> Why do you people keep claiming that acquire semantics provide 
> >> sequential consistency? I must be missing something.
> 
> > In my view, acquire semantics in the failure case are necessary to 
> > provide sequential consistency, if a failed CAS returns the 
> value that 
> > was read.  Such a CAS can clearly be used as an (expensive) 
> > replacement for a load.  This a failed SC CAS has to 
> provide at least 
> > the samantics of an SC load.  Acquire semantics are clearly not 
> > sufficient, but they are necessary.
> 
> Yes, I was talking about the "not sufficient" part. A failed 
> seq_cst CAS must have seq_cst semantics and not merely 
> acquire semantics if the program is to remain SC. Conversely, 
> a non-seq_cst CAS does not guarantee an SC program under any 
> semantics for the failure case.
> 
> That is why I think that using sequential consistency as an 
> argument for acquire semantics in the failed acquire case is 
> not justified. 
> 
It's certainly not an absolutely convincing argument.  But in the
seq_cst case, we need to preserve the ordering requirements for the
failed case, except for those that become vacuous.  The question then is
whether we ned or want more complicated rules for the other ordering
constraints.

Hans



More information about the cpp-threads mailing list