On Thu, 31 Jan 2002, Maciej W. Rozycki wrote:
> Date: Thu, 31 Jan 2002 23:17:21 +0100 (MET)
> From: Maciej W. Rozycki <firstname.lastname@example.org>
> To: H . J . Lu <email@example.com>
> Cc: GNU C Library <firstname.lastname@example.org>, email@example.com
> Subject: [libc-alpha] Re: PATCH: Fix ll/sc for mips
> On Thu, 31 Jan 2002, H . J . Lu wrote:
> > (__compare_and_swap): Return 0 when failed to compare or swap.
> > * sysdeps/mips/atomicity.h (compare_and_swap): Return 0 when
> > failed to compare or swap.
> Looking at the i486 implementation these are not expected to fail.
> Unless I am missing something...
That's what ``compare'' means in ``compare and swap''. You lock the
memory location at some hardware level and then compare the location
to the specified value. If there is a match, you change the memory
location to the new value. Otherwise you don't, and indicate that
you didn't. That's what ``fail'' means. The comparison failed,
and the operation failed to install the new value. The caller must
detect this and handle that. Algorithms based on atomic
compare-and-swap take failure into account.