Getting user+sys time from other processes

Getting user+sys time from other processes

Post by Andrew Berna » Fri, 09 Jul 1999 04:00:00



I'm trying to port a program to AIX which relies on getting very detailed
CPU usage time from another process (it's a profiler). It's currently
running on a Solaris box, and we've been using the /proc filesystem
to get the times needed (with a PIOCUSAGE ioctl).

The box we're trying to port it to runs AIX 4.1, and does not have a
/proc filesystem. Can someone suggest an equivalent way of getting the
timing information?

Thank you very much,
Drew

--
Drew Bernat                                                      __ ____


 
 
 

Getting user+sys time from other processes

Post by Walsh Brow » Fri, 09 Jul 1999 04:00:00




> I'm trying to port a program to AIX which relies on getting very
detailed
> CPU usage time from another process (it's a profiler). It's currently
> running on a Solaris box, and we've been using the /proc filesystem
> to get the times needed (with a PIOCUSAGE ioctl).

> The box we're trying to port it to runs AIX 4.1, and does not have a
> /proc filesystem. Can someone suggest an equivalent way of getting the
> timing information?

> Thank you very much,
> Drew

> --
> Drew Bernat                                                      __
____

|

|

Take a gander at the getprocs() subroutine.  It is the routine to access
the process table in AIX (must be root to access all processes,
otherwise you only get access to your own).  It reads each process into
a structure called procsinfo (procinfo.h) which contains the user
(pi_ru.ru_utime) and system (pi_ru.ru_stime) times that you are looking
for.

For more info, man getprocs.

-- Walsh

--
Walsh Brown

Sometimes I sit and think...sometimes I just sit.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

Getting user+sys time from other processes

Post by Andrew Berna » Fri, 16 Jul 1999 04:00:00





>> I'm trying to port a program to AIX which relies on getting very
> detailed
>> CPU usage time from another process (it's a profiler). It's currently
>> running on a Solaris box, and we've been using the /proc filesystem
>> to get the times needed (with a PIOCUSAGE ioctl).

>> The box we're trying to port it to runs AIX 4.1, and does not have a
>> /proc filesystem. Can someone suggest an equivalent way of getting the
>> timing information?

>> Thank you very much,
>> Drew
> Take a gander at the getprocs() subroutine.  It is the routine to access
> the process table in AIX (must be root to access all processes,
> otherwise you only get access to your own).  It reads each process into
> a structure called procsinfo (procinfo.h) which contains the user
> (pi_ru.ru_utime) and system (pi_ru.ru_stime) times that you are looking
> for.
> For more info, man getprocs.

To answer my own question... :) getprocs() returns, among other things,
an rusage struct, which contains a timeval struct for user and system
time. At least on my system, it contains seconds and nanoseconds. However,
the resolution is only a hundredth of a second.

Thanks for all the help, everyone!

Drew

--
Drew Bernat                                                      __ ____


 
 
 

1. Getting process information <sys/proc.h>


: I have found an interesting structure in <sys/proc.h> called proc_t. The
: header file also lists a few function prototypes that use the struct,
: pid_entry() and prfind().

: If I am right, I can use these to get information about a process. But
: where do I find these function, i.e. which library.

I don't know how to use pid_entry/prfind, but I have used other
to find process-status/info.
In the kernel there is a pointer to the first process-structure (proc).
This pointer is called 'practive'.  Read this, and you know where
the process-list starts.
You might also want to check out kvm_getproc(3K) and kvm_nextproc(3K).
You can also get some interesting stuff by opening the /proc/pid file,
and do a PIOCPSINFO-ioctl on the file-desc (se proc(4)).

: Thanks,

: zeppelin

--

Utleirveien 6
7033 Trondheim
Norway

2. Pseudo keyboard woes

3. 24 hour processing; not time to do sys maintenance

4. SCO vs. Linux

5. user/sys CPU utilization per process?

6. Etherworks 3/Turbo DE203

7. message passing between user processes AND between a user process and kernel space

8. Summary: Re: root partition full, can't login..

9. How to Kill a process and its sub-process and its sub-process at a time..

10. Getting PID at process start up time

11. Getting wall-clock time of process

12. getting process i/o wasted time ...

13. getting the start time of a process in seconds