*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> uscas (3p)              


USCAS(3P)							     USCAS(3P)

NAME    [Toc]    [Back]

     uscas, uscas32 - compare and swap operator

C SYNOPSIS    [Toc]    [Back]

     #include <ulocks.h>

     int  uscas(void *destp, ptrdiff_t old, ptrdiff_t new, usptr_t *u);
     int  uscas32(void *destp, int32_t old, int32_t new, usptr_t *u);

DESCRIPTION    [Toc]    [Back]

     uscas emulates a hardware compare and swap	instruction.  It works on both
     single and	multi-processor	machines.  The exact algorithm used depends on
     the chip and system type.	uscas checks that the contents of destp	are
     equal to old and if they are, atomically changes the contents of destp to
     new.  If the contents are not the same, a zero is returned	and the
     operation may be repeated.	 Note that even	with one process performing
     this algorithm, the compare and swap operation may	fail, so the caller
     must always be prepared to	loop.  u points	to a previously	set up arena
     (using usinit(3P)).

     uscas does	a compare and swap on 32-bits for 32-bit processes and 64-bits
     for 64-bit	processes.
     uscas32 does a compare and	swap on	32-bits	regardless of the type of the

SEE ALSO    [Toc]    [Back]

     acquire_lock(3), usinit(3P), ussetlock(3P), uspsema(3P).

DIAGNOSTICS    [Toc]    [Back]

     A value of	1 returned when	a successful compare and swap has been
     performed.	 Otherwise 0 is	returned.  There are no	errors.

									PPPPaaaaggggeeee 1111
[ Back ]
 Similar pages
Name OS Title
join FreeBSD relational database operator
join IRIX relational database operator
operator OpenBSD C operator precedence and associativity
join HP-UX relational database operator
join OpenBSD relational database operator
operator NetBSD C operator precedence and associativity
operator FreeBSD C operator precedence and order of evaluation
swab Tru64 Swap bytes
swab IRIX swap bytes
swab OpenBSD swap adjacent bytes
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service