home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime.austin.ibm.com!chukran.austin.ibm.com!rudy
- From: rudy@chukran.austin.ibm.com
- Newsgroups: comp.unix.aix
- Subject: Re: swap instruction in assembler?
- Keywords: n
- Message-ID: <1992Nov11.173552.1501@awdprime.austin.ibm.com>
- Date: 11 Nov 92 17:35:52 GMT
- References: <471@bertha.HyperDesk.com> <1992Nov6.165216.652@awdprime.austin.ibm.com>
- Sender: news@awdprime.austin.ibm.com (USENET News)
- Reply-To: chukran@austin.vnet.ibm.com(Rudy Chukran)
- Organization: IBM Advanced Workstation Division
- Lines: 33
-
- In article <1992Nov6.165216.652@awdprime.austin.ibm.com>, ransom@perelandra.austin.ibm.com (Jeff Peek) writes:
- |> The hardware doesn't have a test-and-set instruction available. However,
- |> the operating system has implemented in AIX 3.2 a fast SVC called cs().
- |> The prototype is int cs(int *, int, int). This does cause a "trap" to the
- |> OS, but this code is fast pathed through the system call handler and is
- |> coded in a few assembler instruction that will atomically do the operation.
- |> As long as the address passed is not misaligned, there should be no problem.
- cs has been there since AIX 3.1, if anybody cares. However, to put in a "plug"
- for an interface new in AIX 3.2:
-
- If you need a light weight semaphore, Id suggest also looking into the
- msem_lock binary semaphore interface. It uses cs to set the lock word
- in shared memory. It will block if the word is already locked.
- Measurements show that msem_lock is 30 times faster than semop when the
- semaphore isnt already locked (uncontended case).
-
- Otherwise, the process which contends the lock must do something. If it
- it should do some useful processing, then do it. If it must sleep, then
- Id recommend using the msem_lock. It is the most efficient on AIX for
- multiple waiters.
-
- Im just trying to get the word out about a little known interface that
- is new to AIX 3.2 that solves a very specific problem with fast
- process syncronization. The set of interfaces to look up are
- msem_init, msem_lock, msem_unlock.
- --
- *********************************************************************
- Rudy Chukran | EMAIL:
- IBM AIX Technical Consulting| RSCS: CHUKRAN at AUSTIN
- 11400 Burnet Rd. | AWDnet:rudy@chukran.austin.ibm.com
- Internal ZIP 2830 | internet: chukran@austin.vnet.ibm.com
- Austin, Texas 78758 |
- *********************************************************************
-