BSD 4_4 development
[unix-history] / usr / share / man / cat2 / getrusage.0
GETRUSAGE(2) BSD Programmer's Manual GETRUSAGE(2)
N\bNA\bAM\bME\bE
g\bge\bet\btr\bru\bus\bsa\bag\bge\be - get information about resource utilization
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bti\bim\bme\be.\b.h\bh>\b>
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/r\bre\bes\bso\bou\bur\brc\bce\be.\b.h\bh>\b>
#\b#d\bde\bef\bfi\bin\bne\be R\bRU\bUS\bSA\bAG\bGE\bE_\b_S\bSE\bEL\bLF\bF 0\b0
#\b#d\bde\bef\bfi\bin\bne\be R\bRU\bUS\bSA\bAG\bGE\bE_\b_C\bCH\bHI\bIL\bLD\bDR\bRE\bEN\bN -\b-1\b1
_\bi_\bn_\bt
g\bge\bet\btr\bru\bus\bsa\bag\bge\be(_\bi_\bn_\bt _\bw_\bh_\bo, _\bs_\bt_\br_\bu_\bc_\bt _\br_\bu_\bs_\ba_\bg_\be _\b*_\br_\bu_\bs_\ba_\bg_\be);
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
G\bGe\bet\btr\bru\bus\bsa\bag\bge\be() returns information describing the resources utilized by the
current process, or all its terminated child processes. The _\bw_\bh_\bo parame-
ter is either RUSAGE_SELF or RUSAGE_CHILDREN. The buffer to which _\br_\bu_\bs_\ba_\bg_\be
points will be filled in with the following structure:
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
long ru_maxrss; /* integral max resident set size */
long ru_ixrss; /* integral shared text memory size */
long ru_idrss; /* integral unshared data size */
long ru_isrss; /* integral unshared stack size */
long ru_minflt; /* page reclaims */
long ru_majflt; /* page faults */
long ru_nswap; /* swaps */
long ru_inblock; /* block input operations */
long ru_oublock; /* block output operations */
long ru_msgsnd; /* messages sent */
long ru_msgrcv; /* messages received */
long ru_nsignals; /* signals received */
long ru_nvcsw; /* voluntary context switches */
long ru_nivcsw; /* involuntary context switches */
};
The fields are interpreted as follows:
_\br_\bu_\b__\bu_\bt_\bi_\bm_\be the total amount of time spent executing in user mode.
_\br_\bu_\b__\bs_\bt_\bi_\bm_\be the total amount of time spent in the system executing on
behalf of the process(es).
_\br_\bu_\b__\bm_\ba_\bx_\br_\bs_\bs the maximum resident set size utilized (in kilobytes).
_\br_\bu_\b__\bi_\bx_\br_\bs_\bs an integral value indicating the amount of memory used by
the text segment that was also shared among other processes.
This value is expressed in units of kilobytes * ticks-of-
execution.
_\br_\bu_\b__\bi_\bd_\br_\bs_\bs an integral value of the amount of unshared memory residing
in the data segment of a process (expressed in units of
kilobytes * ticks-of-execution).
_\br_\bu_\b__\bi_\bs_\br_\bs_\bs an integral value of the amount of unshared memory residing
in the stack segment of a process (expressed in units of
kilobytes * ticks-of-execution).
_\br_\bu_\b__\bm_\bi_\bn_\bf_\bl_\bt 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.
_\br_\bu_\b__\bm_\ba_\bj_\bf_\bl_\bt the number of page faults serviced that required I/O activi-
ty.
_\br_\bu_\b__\bn_\bs_\bw_\ba_\bp the number of times a process was swapped out of main memo-
ry.
_\br_\bu_\b__\bi_\bn_\bb_\bl_\bo_\bc_\bk the number of times the file system had to perform input.
_\br_\bu_\b__\bo_\bu_\bb_\bl_\bo_\bc_\bk the number of times the file system had to perform output.
_\br_\bu_\b__\bm_\bs_\bg_\bs_\bn_\bd the number of IPC messages sent.
_\br_\bu_\b__\bm_\bs_\bg_\br_\bc_\bv the number of IPC messages received.
_\br_\bu_\b__\bn_\bs_\bi_\bg_\bn_\ba_\bl_\bs the number of signals delivered.
_\br_\bu_\b__\bn_\bv_\bc_\bs_\bw the number of times a context switch resulted due to a pro-
cess voluntarily giving up the processor before its time
slice was completed (usually to await availability of a re-
source).
_\br_\bu_\b__\bn_\bi_\bv_\bc_\bs_\bw the number of times a context switch resulted due to a high-
er priority process becoming runnable or because the current
process exceeded its time slice.
N\bNO\bOT\bTE\bES\bS
The numbers _\br_\bu_\b__\bi_\bn_\bb_\bl_\bo_\bc_\bk and _\br_\bu_\b__\bo_\bu_\bb_\bl_\bo_\bc_\bk account only for real I/O; data
supplied by the caching mechanism is charged only to the first process to
read or write the data.
E\bER\bRR\bRO\bOR\bRS\bS
G\bGe\bet\btr\bru\bus\bsa\bag\bge\be() returns -1 on error. The possible errors are:
[EINVAL] The _\bw_\bh_\bo parameter is not a valid value.
[EFAULT] The address specified by the _\br_\bu_\bs_\ba_\bg_\be parameter is not in a
valid part of the process address space.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
gettimeofday(2), wait(2)
B\bBU\bUG\bGS\bS
There is no way to obtain information about a child process that has not
yet terminated.
H\bHI\bIS\bST\bTO\bOR\bRY\bY
The g\bge\bet\btr\bru\bus\bsa\bag\bge\be function call appeared in 4.2BSD.
4th Berkeley Distribution June 4, 1993 2