On Fri, 16 Dec 2005, David Howells wrote:
>
> Of course, CMPXCHG doesn't have to store either, though it still performs a
> locked-write-cycle on x86 if I remember correctly.
It does so on any sane architecture (side note: you don't do locked
memory cycles on the bus these days. You do cache coherency protocols).
>From a bus standpoint you _have_ to do the initial read with intent to
write, nothing else makes any sense. You'll just waste bus cycles
otherwise. Sure, the write may never come, but it just isn't sensible to
optimize for the case where the compare will fail. If that's the common
case, then software is doing something wrong (it should do just a much
cheaper "load + compare" first if it knows it's probably going to fail).
Linus