1GETRUSAGE(2)                  System Calls Manual                 GETRUSAGE(2)
2
3
4

NAME

6       getrusage - get information about resource utilization
7

SYNOPSIS

9       #include <sys/time.h>
10       #include <sys/resource.h>
11
12       #define RUSAGE_SELF      0         /* calling process */
13       #define RUSAGE_CHILDREN  -1        /* terminated child processes */
14
15       getrusage(who, rusage)
16       int who;
17       struct rusage *rusage;
18

DESCRIPTION

20       Getrusage  returns information describing the resources utilized by the
21       current process, or all its terminated child processes.  The who param‐
22       eter  is  one  of  RUSAGE_SELF or RUSAGE_CHILDREN.  The buffer to which
23       rusage points will be filled in with the following structure:
24
25              struct  rusage {
26                      struct timeval ru_utime;        /* user time used */
27                      struct timeval ru_stime;        /* system time used */
28                      long    ru_maxrss;
29                      long    ru_ixrss;               /* integral shared text memory size */
30                      long    ru_idrss;               /* integral unshared data size */
31                      long    ru_isrss;               /* integral unshared stack size */
32                      long    ru_minflt;              /* page reclaims */
33                      long    ru_majflt;              /* page faults */
34                      long    ru_ovly;                /* overlay changes */
35                      long    ru_nswap;               /* swaps */
36                      long    ru_inblock;             /* block input operations */
37                      long    ru_oublock;             /* block output operations */
38                      long    ru_msgsnd;              /* messages sent */
39                      long    ru_msgrcv;              /* messages received */
40                      long    ru_nsignals;            /* signals received */
41                      long    ru_nvcsw;               /* voluntary context switches */
42                      long    ru_nivcsw;              /* involuntary context switches */
43              };
44
45       The fields are interpreted as follows:
46
47       ru_utime       the total amount of time spent executing in user mode.
48
49       ru_stime       the total amount of time spent in the  system  executing
50                      on behalf of the process(es).
51
52       ru_maxrss      the maximum resident set size utilized (in kilobytes).
53
54       ru_ixrss       an “integral” value indicating the amount of memory used
55                      by the text segment that was  also  shared  among  other
56                      processes.   This  value  is expressed in units of kilo‐
57                      bytes * seconds-of-execution and is calculated  by  sum‐
58                      ming  the number of shared memory pages in use each time
59                      the internal system clock ticks and then averaging  over
60                      1 second intervals.
61
62       ru_idrss       an  integral  value  of  the  amount  of unshared memory
63                      residing in the data segment of a process (expressed  in
64                      units of kilobytes * seconds-of-execution).
65
66       ru_isrss       an  integral  value  of  the  amount  of unshared memory
67                      residing in the stack segment of a process (expressed in
68                      units of kilobytes * seconds-of-execution).
69
70       ru_minflt      the  number  of  page  faults  serviced  without any I/O
71                      activity; here I/O activity is avoided by “reclaiming” a
72                      page frame from the list of pages awaiting reallocation.
73
74       ru_majflt      the  number  of  page  faults serviced that required I/O
75                      activity.
76
77       the number of times a process requested a text overlay switch -
78                      only available under 2_10BSD.
79
80       ru_nswap       the number of times a process was “swapped” out of  main
81                      memory.
82
83       ru_inblock     the  number  of  times  the  file  system had to perform
84                      input.
85
86       ru_outblock    the number of times the file system had to perform  out‐
87                      put.
88
89       ru_msgsnd      the number of IPC messages sent.
90
91       ru_msgrcv      the number of IPC messages received.
92
93       ru_nsignals    the number of signals delivered.
94
95       ru_nvcsw       the  number  of times a context switch resulted due to a
96                      process voluntarily giving up the processor  before  its
97                      time  slice was completed (usually to await availability
98                      of a resource).
99
100       ru_nivcsw      the number of times a context switch resulted due  to  a
101                      higher priority process becoming runnable or because the
102                      current process exceeded its time slice.
103

NOTES

105       The numbers ru_inblock and ru_outblock account only for real I/O;  data
106       supplied  by the caching mechanism is charged only to the first process
107       to read or write the data.
108

ERRORS

110       The possible errors for getrusage are:
111
112       [EINVAL]       The who parameter is not a valid value.
113
114       [EFAULT]       The address specified by the rusage parameter is not  in
115                      a valid part of the process address space.
116

SEE ALSO

118       gettimeofday(2), wait(2)
119

BUGS

121       There  is  no  way to obtain information about a child process that has
122       not yet terminated.
123
124
125
1264th Berkeley Distribution        May 13, 1986                     GETRUSAGE(2)
Impressum