From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653646721761.tru64-unix-managers.marc@archive.invalid> From: "Markley, Sean" Date: Fri, 27 Apr 2001 12:27:59 +0000 To: tru64-unix-managers Subject: SUMMARY: Semaphore counting question X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653646721761 Managers, Thanks first to those who responded: Steve Butcher Serguei Patchkovskii It looks like no one responded with a c version of this, but this simple shell script does the trick. It is a bit modified from what Steve/Serguei sent me. If anyone still has an idea how to do this in c - it would be appreciated. #!/usr/bin/ksh ipcs -s -a |tail +4 |awk ' {s += $9} END { print "sum is", s} ' Managers, Would anyone have a quick and dirty method for counting semaphores? IPCS will give you the number of sets, and how many semaphores there are in each set, but it's not the greatest. I suppose if I had source for ipcs and could add the nsems column for each set I'd retrieved, I'd be OK. Which, if someone has that, it would be great. The only other restriction I have, though, is I'd like this to be portable (but if it's not I'd still like to see it). I know I could use awk/cut and cut out the nsems field, store it to a variable and count em up, but I'd also like something cleaner, and preferably in c as the semaphore operations look pretty portable. I looked at semget, and maybe I'm missing it, but will semget somehow return the key values for all semaphore sets? Looks like to me it either creates the key (supplied or otherwise) or returns its value if it already exists. It doesn't appear to have any way to return all key values. How does ipcs do it? Boiling the question down: ipcs -s | tail +4 | wc -l will give you the number of sets(3 - below). How do I determine (with c, shell, or othewise) the total number of semaphores listed in all sets? $ ipcs -s -a IPC status from as of Thu Apr 26 15:32:25 2001 T ID KEY MODE OWNER GROUP CREATOR CGROUP NSEMS OTIME CTIME Semaphores: s 196608 0x0000000d --ra-ra-ra- root other root other 51 15:32:25 14:30:41 s 1835009 00000000 --ra-ra-ra- dev dev dev dev 2 10:53:52 10:51:45 s 2031618 00000000 --ra-ra-ra- dev dev dev dev 2 14:09:55 10:53:44 .... Total # of semaphores in this case: 55 (what I would be looking for - preferably in c) Sean Markley Software Engineer, ManageIT/Performance Level 2 Computer Associates International, Inc. Email: Sean.Markley@ca.com