- The getrusage system call retrieves process statistics from the kernel.
- It can be used to obtain statistics either for the current process by passing RUSAGE_SELF as the first argument,
- or for all terminated child processes that were forked by this process and its children by passing RUSAGE_CHILDREN.
- A few of the more interesting fields in struct rusage are listed here:
- ru_utime A struct timevalue field containing the amount of user time, in seconds, that the process has used. User time is CPU time spent executing the user program, rather than in kernel system calls.
- ru_stime A struct timevalue field containing the amount of system time, in seconds, that the process has used. System time is the CPU time spent executing system calls on behalf of the process.
- ru_maxrss The largest amount of physical memory occupied by the process's data at one time over the course of its execution.
- The http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/print-cpu-times.c function in Fig. 5 prints out the current process's user and system time.
Figure 5:
Display Process User and System Times.
|
2006-04-27