home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:4265 comp.unix.internals:1684
- Path: sparky!uunet!sun-barr!male.EBay.Sun.COM!west.West.Sun.COM!cronkite.Central.Sun.COM!texsun!ttsi!mse
- From: mse@ttsi.lonestar.org (Mark Evans)
- Newsgroups: comp.unix.programmer,comp.unix.internals
- Subject: Re: SVR4 semaphore overhead???
- Message-ID: <1992Aug13.020203.7490@ttsi.lonestar.org>
- Date: 13 Aug 92 02:02:03 GMT
- References: <1992Aug8.131020.17966@ttsi.lonestar.org>
- Organization: st
- Lines: 51
-
- In article <1992Aug8.131020.17966@ttsi.lonestar.org> I wrote:
- >I have seen postings from time to time regarding the overhead of
- >semaphores in SVR4, but not many followups. I'm now in the boat
- >of considering the usage of semaphores for mutual exclusion and
- >resource coordination between a substantial number (~30) of
- >processes. There is a potential for a large number of semaphores
- >(60-90) to get allocated.
- >
- >Someone recently posted an observation that as the number of
- >semaphores in a system grows, so does the overhead. Can anyone
- >confirm this?
-
- On a Tandem Integrity R3000 machine running SVR4, I found no
- degradation in performance on a given semaphore as the number of
- semaphores in a set increased from 1 to 25 (current sysgen'd max).
- I am chagrined, however, at the 70 microseconds or so taken to
- do a simple semop() lock, as compared to the .82 microseconds it
- takes to call _test_and_set(), a mips-supplied routine in
- libc.a which performs an indivisible test-and-set (actually, it's
- read-modify-write). As suggested in previous articles and by
- respondents to my original post, I am cooking up a
- lightweight semaphore package using _test_and_test() for the
- lock, and system semaphores (or message queue or pause/signal)
- for sleep/wakeup when contention arises.
-
- A couple of questions have come up that require expert knowledge:
-
- (1) Is there a way for a process to reschedule itself, i.e., go to
- the end of the current ready-to-run list? I don't want to resort
- to a sleep_ms() call if I can avoid it.
-
- (2) When multiple processes contend for a system semaphore, are
- they rewarded in FIFO order as the semaphore becomes available?
- I have gotten the impression from previous testing that this is not so.
- Can anyone explain the data structures & algorithm used behind the
- scenes?
-
- Writing this simple lock/unlock package at the user level without
- resorting to priority controls is surprisingly mind-boggling if you
- consider all the races. I'm on my fourth "I've got it" approach.
- When I really do "have it," I'll happily share the results to the
- many who have expressed interest in the subject. If you think
- you have a solution, I know many out here would love to see it.
-
- Thanks
-
- --
- Mark S. Evans Tandem Telecommunications Systems Inc.
- Phone: 214-516-6201 1255 W 15th St.
- Fax: 214-516-6805 Plano, TX 75075
- Mail: mse@ttsi.lonestar.org
-