home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.centerline.com!noc.near.net!bertha!sweetjane.hyperdesk.com!adennie
- From: adennie@sweetjane.hyperdesk.com (Andy Dennie)
- Newsgroups: comp.unix.aix
- Subject: swap instruction in assembler?
- Message-ID: <471@bertha.HyperDesk.com>
- Date: 6 Nov 92 00:20:41 GMT
- Sender: usenet@bertha.HyperDesk.com
- Reply-To: andy_d@hyperdesk.com
- Followup-To: comp.unix.aix
- Organization: HyperDesk Corporation, Westboro, MA
- Lines: 22
-
-
- I need to implement a semaphore-like test-and-set operation in assembler
- on the RS/6000. The functionality is: if an address contains a 0, set
- it to 1 and return 1; if it contains a 1, return 0.
-
- Since the address is in shared memory, I need to worry about another
- process getting the time slice between my test and my set, and setting
- it before I get the chance to set it myself.
-
- What I'd like to do is:
- store 1 in register
- swap register with address
- if register contains 1, the semaphore belongs to somebody else,
- so return 0
- otherwise return 1
-
- My problem: I don't see a swap instruction in the manual. Is there
- another instruction that might do what I want?
-
- Thanks for your help,
- Andy Dennie
- --
-