Manual Pages for Linux CentOS command on man getrusage
MyWebUniversity

Manual Pages for Linux CentOS command on man getrusage

GETRUSAGE(2) Linux Programmer's Manual GETRUSAGE(2)

NAME

getrusage - get resource usage SYNOPSIS

#include

#include int getrusage(int who, struct rusage *usage); DESCRIPTION getrusage() returns resource usage measures for who, which can be one of the following: RUSAGESELF Return resource usage statistics for the calling process, which is the sum of resources used by all threads in the process. RUSAGECHILDREN Return resource usage statistics for all children of the calling process that have terminated and been waited for. These statis‐ tics will include the resources used by grandchildren, and fur‐ ther removed descendants, if all of the intervening descendants waited on their terminated children. RUSAGETHREAD (since Linux 2.6.26) Return resource usage statistics for the calling thread. The resource usages are returned in the structure pointed to by usage, which has the following form: struct rusage { struct timeval ruutime; /* user CPU time used */ struct timeval rustime; /* system CPU time used */ long rumaxrss; /* maximum resident set size */ long ruixrss; /* integral shared memory size */ long ruidrss; /* integral unshared data size */ long ruisrss; /* integral unshared stack size */ long ruminflt; /* page reclaims (soft page faults) */ long rumajflt; /* page faults (hard page faults) */ long runswap; /* swaps */ long ruinblock; /* block input operations */ long ruoublock; /* block output operations */ long rumsgsnd; /* IPC messages sent */ long rumsgrcv; /* IPC messages received */ long runsignals; /* signals received */ long runvcsw; /* voluntary context switches */ long runivcsw; /* involuntary context switches */ }; Not all fields are completed; unmaintained fields are set to zero by the kernel. (The unmaintained fields are provided for compatibility with other systems, and because they may one day be supported on Linux.) The fields are interpreted as follows: ruutime This is the total amount of time spent executing in user mode, expressed in a timeval structure (seconds plus microseconds). rustime This is the total amount of time spent executing in kernel mode, expressed in a timeval structure (seconds plus microseconds). rumaxrss (since Linux 2.6.32) This is the maximum resident set size used (in kilobytes). For RUSAGECHILDREN, this is the resident set size of the largest child, not the maximum resident set size of the process tree. ruixrss (unmaintained) This field is currently unused on Linux. ruidrss (unmaintained) This field is currently unused on Linux. ruisrss (unmaintained) This field is currently unused on Linux. ruminflt The number of page faults serviced without any I/O activity; here I/O activity is avoided by “reclaiming” a page frame from the list of pages awaiting reallocation. rumajflt The number of page faults serviced that required I/O activity. runswap (unmaintained) This field is currently unused on Linux. ruinblock (since Linux 2.6.22) The number of times the file system had to perform input. ruoublock (since Linux 2.6.22) The number of times the file system had to perform output. rumsgsnd (unmaintained) This field is currently unused on Linux. rumsgrcv (unmaintained) This field is currently unused on Linux. runsignals (unmaintained) This field is currently unused on Linux. runvcsw (since Linux 2.6) The number of times a context switch resulted due to a process voluntarily giving up the processor before its time slice was completed (usually to await availability of a resource). runivcsw (since Linux 2.6) The number of times a context switch resulted due to a higher priority process becoming runnable or because the current process exceeded its time slice. RETURN VALUE

On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS EFAULT usage points outside the accessible address space. EINVAL who is invalid. CONFORMING TO

SVr4, 4.3BSD. POSIX.1-2001 specifies getrusage(), but specifies only the fields ruutime and rustime.

RUSAGETHREAD is Linux-specific. NOTES Resource usage metrics are preserved across an execve(2). Including is not required these days, but increases porta‐ bility. (Indeed, struct timeval is defined in .) In Linux kernel versions before 2.6.9, if the disposition of SIGCHLD is set to SIGIGN then the resource usages of child processes are automat‐ ically included in the value returned by RUSAGECHILDREN, although

POSIX.1-2001 explicitly prohibits this. This nonconformance is recti‐ fied in Linux 2.6.9 and later. The structure definition shown at the start of this page was taken from 4.3BSD Reno. Ancient systems provided a vtimes() function with a similar purpose to getrusage(). For backward compatibility, glibc also provides vtimes(). All new applications should be written using getrusage(). See also the description of /proc/PID/stat in proc(5). SEE ALSO clockgettime(2), getrlimit(2), times(2), wait(2), wait4(2), clock(3) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

Linux 2010-09-26 GETRUSAGE(2)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™