home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / aix / 11329 < prev    next >
Encoding:
Internet Message Format  |  1992-11-06  |  1.1 KB

  1. Path: sparky!uunet!news.centerline.com!noc.near.net!bertha!sweetjane.hyperdesk.com!adennie
  2. From: adennie@sweetjane.hyperdesk.com (Andy Dennie)
  3. Newsgroups: comp.unix.aix
  4. Subject: swap instruction in assembler?
  5. Message-ID: <471@bertha.HyperDesk.com>
  6. Date: 6 Nov 92 00:20:41 GMT
  7. Sender: usenet@bertha.HyperDesk.com
  8. Reply-To: andy_d@hyperdesk.com
  9. Followup-To: comp.unix.aix
  10. Organization: HyperDesk Corporation, Westboro, MA
  11. Lines: 22
  12.  
  13.  
  14. I need to implement a semaphore-like test-and-set operation in assembler
  15. on the RS/6000.  The functionality is: if an address contains a 0, set
  16. it to 1 and return 1; if it contains a 1, return 0.
  17.  
  18. Since the address is in shared memory, I need to worry about another
  19. process getting the time slice between my test and my set, and setting
  20. it before I get the chance to set it myself.
  21.  
  22. What I'd like to do is:
  23.      store 1 in register
  24.      swap register with address
  25.      if register contains 1, the semaphore belongs to somebody else,
  26.           so return 0
  27.      otherwise return 1
  28.  
  29. My problem: I don't see a swap instruction in the manual.  Is there
  30. another instruction that might do what I want?
  31.  
  32. Thanks for your help,
  33.      Andy Dennie
  34. -- 
  35.