[comp.unix.wizards] Getting CPU information on unterminatted child processes

leight@mozart.amd.com (Timothy Leight) (08/08/90)

I am interested in getting accurate cpu usage information
on unterminated child processes. The getrusage() and/or times()
system calls only return information on terminated children.

What is the best method for getting this information?


thanks in advance
tim leight

leight@mozart.amd.com

jak@sactoh0.UUCP (Jay A. Konigsberg) (08/11/90)

In article <1990Aug7.215320.13715@mozart.amd.com> leight@mozart.amd.com (Timothy Leight) writes:
>I am interested in getting accurate cpu usage information
>on unterminated child processes. The getrusage() and/or times()
>system calls only return information on terminated children.
>
>What is the best method for getting this information?
>
Well, I don't know the best method, but I think I can point you in the
right direction (since no one else did).

ps -lf will provide much of the information needed, though it may not
produce enough and any way you invoke it (peopen or shell script), it
will be slow.

Another aproach is to get the information directly out of /dev/kmem.
However, all I know how to do there is get overall system usage
parameters. Specific information of /dev/kmem is probably system
specific and un-portable. However, the Sys V and Xenix 2.3.? header
file is: /usr/include/sys/sysinfo.h

Getting information about kernel level data structures on the net is
a little like asking for the moon, no one seems to have it. Anyway,
perhaps this post will generate a little discussion. I would like to
know more specifics about the Sys V kernel myself.

-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.

guy@auspex.auspex.com (Guy Harris) (08/12/90)

>Getting information about kernel level data structures on the net is
>a little like asking for the moon, no one seems to have it.

No, it's more like asking for the moon if you're on Jupiter; the
appropriate response is "which moon"?  Kernel-level data structures
differ between different UNIX implementations.

jak@sactoh0.UUCP (Jay A. Konigsberg) (08/13/90)

In article <3879@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
>>Getting information about kernel level data structures on the net is
>>a little like asking for the moon, no one seems to have it.
>
>No, it's more like asking for the moon if you're on Jupiter; the
>appropriate response is "which moon"?  Kernel-level data structures
>differ between different UNIX implementations.
>
This is true, however, the number of Sys V/Xenix and BSD/Sun systems
out there cover the majority of systems. That means there should be 
only two general answers with the detail left out. When _all_ systems
are included, the number of answers goes up. Still, it would be nice
to get more kernel data-structure information.

I saw a program once called "top". Basically, its a `ps -ef` listing
where the processes that are using the most CPU time are listed on
top. Nice program, the author had the info I (and others) are looking
for. I don't know if it was Sys V or BSD because it was on a two-universe
machine (amazing in itself).

-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.

grant@Pescara.ORC.Olivetti.Com (Grant Grundler) (08/14/90)

System Vr4 has a /proc file system which allows the average user to
read process memory space as if it where a file.  The user must normally
have access to the process.  On sysV4, ps also gets the info from here.
On older systems I would also use "ps" as suggested by jak@sactoh0.UUCP.

grant

ag@cbmvax.commodore.com (Keith Gabryelski) (08/15/90)

In article <3699@sactoh0.UUCP> jak@sactoh0.UUCP (Jay A. Konigsberg) writes:
>In article <3879@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
>>>Getting information about kernel level data structures on the net is
>>>a little like asking for the moon, no one seems to have it.
>>
>>No, it's more like asking for the moon if you're on Jupiter; the
>>appropriate response is "which moon"?  Kernel-level data structures
>>differ between different UNIX implementations.
>
>This is true, however, the number of Sys V/Xenix and BSD/Sun systems
>out there cover the majority of systems.

I would say not.  For instance, getting the user structure for a
certain process is different depending the version of Xenix you are
running (2.1 or 3.2) and what machine you are running on (286 or
386).

Some Unix Systems use a system call to find such information; 3b2 use
sys3b(); 3b1 use syslocal().

System V Release 4.0 does the /proc thing.

That is six different ways (no Xenix 3.2/286) of handling the same
operation under systems you would group under SysV/Xenix; Ackphfffftt!

Guy is correct--``Which moon'' is the response you should expect if you
ask about kernel specifics without giving any detail about the target
system.

Pax, Keith