Commit | Line | Data |
---|---|---|
3031ff5e KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
a525da8e | 5 | .\" @(#)getrusage.2 6.5 (Berkeley) %G% |
3031ff5e | 6 | .\" |
c11fc4d8 | 7 | .TH GETRUSAGE 2 "" |
3031ff5e KM |
8 | .UC 4 |
9 | .SH NAME | |
852d175d | 10 | getrusage \- get information about resource utilization |
3031ff5e KM |
11 | .SH SYNOPSIS |
12 | .nf | |
852d175d KM |
13 | .ft B |
14 | #include <sys/time.h> | |
15 | #include <sys/resource.h> | |
3031ff5e | 16 | .PP |
852d175d KM |
17 | .ft B |
18 | .ta \w'#define 'u +\w'RUSAGE_CHILDREN 'u +\w'-1 'u | |
19 | #define RUSAGE_SELF 0 /* calling process */ | |
20 | #define RUSAGE_CHILDREN -1 /* terminated child processes */ | |
21 | .DT | |
22 | .PP | |
23 | .ft B | |
24 | getrusage(who, rusage) | |
25 | int who; | |
26 | struct rusage *rusage; | |
3031ff5e KM |
27 | .fi |
28 | .SH DESCRIPTION | |
852d175d KM |
29 | .I Getrusage |
30 | returns information describing the resources utilized by the current | |
31 | process, or all its terminated child processes. | |
32 | The | |
33 | .I who | |
0b3847f7 MK |
34 | parameter is one of RUSAGE_SELF or RUSAGE_CHILDREN. |
35 | The buffer to which | |
852d175d | 36 | .I rusage |
0b3847f7 | 37 | points will be filled in with |
852d175d | 38 | the following structure: |
3031ff5e KM |
39 | .PP |
40 | .nf | |
852d175d KM |
41 | .RS |
42 | .ta \w'struct 'u +\w'struct 'u +3u*\w'struct 'u | |
43 | struct rusage { | |
44 | struct timeval ru_utime; /* user time used */ | |
45 | struct timeval ru_stime; /* system time used */ | |
46 | int ru_maxrss; | |
0b3847f7 | 47 | int ru_ixrss; /* integral shared text memory size */ |
852d175d KM |
48 | int ru_idrss; /* integral unshared data size */ |
49 | int ru_isrss; /* integral unshared stack size */ | |
50 | int ru_minflt; /* page reclaims */ | |
51 | int ru_majflt; /* page faults */ | |
52 | int ru_nswap; /* swaps */ | |
53 | int ru_inblock; /* block input operations */ | |
54 | int ru_oublock; /* block output operations */ | |
55 | int ru_msgsnd; /* messages sent */ | |
56 | int ru_msgrcv; /* messages received */ | |
57 | int ru_nsignals; /* signals received */ | |
58 | int ru_nvcsw; /* voluntary context switches */ | |
59 | int ru_nivcsw; /* involuntary context switches */ | |
60 | }; | |
61 | .RE | |
62 | .DT | |
3031ff5e | 63 | .fi |
852d175d KM |
64 | .PP |
65 | The fields are interpreted as follows: | |
66 | .TP 15 | |
67 | ru_utime | |
68 | the total amount of time spent executing in user mode. | |
69 | .TP 15 | |
70 | ru_stime | |
71 | the total amount of time spent in the system executing on behalf | |
72 | of the process(es). | |
73 | .TP 15 | |
74 | ru_maxrss | |
75 | the maximum resident set size utilized (in kilobytes). | |
76 | .TP 15 | |
77 | ru_ixrss | |
78 | an \*(lqintegral\*(rq value indicating the amount of memory used | |
0b3847f7 | 79 | by the text segment |
63b0bb9c | 80 | that was also shared among other processes. This value is expressed |
852d175d KM |
81 | in units of kilobytes * seconds-of-execution and is calculated by |
82 | summing the number of shared memory pages in use each time the internal | |
83 | system clock ticks and then averaging over 1 second intervals. | |
84 | .TP 15 | |
85 | ru_idrss | |
86 | an integral value of the amount of unshared memory residing in the | |
87 | data segment of a process (expressed in units of | |
88 | kilobytes * seconds-of-execution). | |
89 | .TP 15 | |
90 | ru_isrss | |
91 | an integral value of the amount of unshared memory residing in the | |
92 | stack segment of a process (expressed in units of | |
93 | kilobytes * seconds-of-execution). | |
94 | .TP 15 | |
95 | ru_minflt | |
0b3847f7 MK |
96 | the number of page faults serviced without any I/O activity; here |
97 | I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from | |
852d175d KM |
98 | the list of pages awaiting reallocation. |
99 | .TP 15 | |
100 | ru_majflt | |
0b3847f7 | 101 | the number of page faults serviced that required I/O activity. |
852d175d KM |
102 | .TP 15 |
103 | ru_nswap | |
104 | the number of times a process was \*(lqswapped\*(rq out of main | |
105 | memory. | |
106 | .TP 15 | |
107 | ru_inblock | |
108 | the number of times the file system had to perform input. | |
109 | .TP 15 | |
a525da8e | 110 | ru_oublock |
852d175d KM |
111 | the number of times the file system had to perform output. |
112 | .TP 15 | |
113 | ru_msgsnd | |
0b3847f7 | 114 | the number of IPC messages sent. |
852d175d KM |
115 | .TP 15 |
116 | ru_msgrcv | |
0b3847f7 | 117 | the number of IPC messages received. |
852d175d KM |
118 | .TP 15 |
119 | ru_nsignals | |
120 | the number of signals delivered. | |
121 | .TP 15 | |
122 | ru_nvcsw | |
123 | the number of times a context switch resulted due to a process | |
124 | voluntarily giving up the processor before its time slice was | |
125 | completed (usually to await availability of a resource). | |
126 | .TP 15 | |
127 | ru_nivcsw | |
128 | the number of times a context switch resulted due to a higher | |
129 | priority process becoming runnable or because the current process | |
130 | exceeded its time slice. | |
131 | .SH NOTES | |
132 | The numbers | |
133 | .I ru_inblock | |
134 | and | |
a525da8e | 135 | .I ru_oublock |
852d175d | 136 | account only for real |
0b3847f7 | 137 | I/O; data supplied by the caching mechanism is charged only |
852d175d | 138 | to the first process to read or write the data. |
fd690c8b KM |
139 | .SH ERRORS |
140 | The possible errors for | |
141 | .I getrusage | |
142 | are: | |
143 | .TP 15 | |
144 | [EINVAL] | |
145 | The | |
146 | .I who | |
147 | parameter is not a valid value. | |
148 | .TP 15 | |
149 | [EFAULT] | |
150 | The address specified by the | |
151 | .I rusage | |
152 | parameter is not in a valid part of the process address space. | |
852d175d KM |
153 | .SH SEE ALSO |
154 | gettimeofday(2), wait(2) | |
155 | .SH BUGS | |
156 | There is no way to obtain information about a child process | |
63b0bb9c | 157 | that has not yet terminated. |