[cpp-threads] Yet another visibility question

Paul E. McKenney paulmck at linux.vnet.ibm.com
Thu Jan 11 18:41:44 GMT 2007


On Thu, Jan 11, 2007 at 07:19:48PM +0100, Alexander Terekhov wrote:
> On 1/11/07, Paul E. McKenney <paulmck at linux.vnet.ibm.com> wrote:
> 
> [... AMD x86-64 ...]
> 
> >       do {
> >               l = x;
> >       } while (cmpxchg(&x, l, l) != l);
> 
> Regarding providing illusion of remote write atomicity (under
> assumption that AMD x86-64 is PC and not TSO) that's no better than
> 
>        l = cmpxchg(&x, 42, 42); // with LOCK prefix
> 
> because (quoting AMD64 Architecture Programmer's Manual Volume 3)
> 
> "CMPXCHG always does a read-modify-write on the memory operand. If the
> compared operands were unequal, CMPXCHG writes the same value to the
> memory operand that was read."

Good point -- I stand corrected!

							Thanx, Paul



More information about the cpp-threads mailing list