Path: utzoo!attcan!uunet!bywater!arnor!arnor!marc From: marc@arnor.uucp Newsgroups: comp.unix.aix Subject: Re: cs system call on RS/6000 Message-ID: Date: 10 Dec 90 13:33:37 GMT References: <1990Dec6.183659.1712@progress.com> Sender: news@arnor.uucp (NNTP News Poster) Organization: IBM T.J. Watson Research Center, Hawthorne, New York Lines: 23 In-Reply-To: tma@progress.COM's message of 6 Dec 90 18:36:59 GMT "cs" follows the "compare and swap" strategy used in the IBM S/370. It is described in the on line documentation, which includes an example. The call is: cs(int *dest, int comp, int value); and the idea is that it will store value in destination only if destination's old value was comp. This is of course done atomically. cs returns 0 if it succeeds, 1 if the old value of destination did not match comp. For examle, to set a simple spin lock in int lock where the lock is 0 when free and 1 when held: while (cs(&lock,0,1)); compare and swap can also be used to do many linked list manipulations directly without ever setting a lock at all. Marc Auslander