Commit | Line | Data |
---|---|---|
92634ce9 KB |
1 | .\" Copyright (c) 1985 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3031ff5e | 3 | .\" |
1c15e888 C |
4 | .\" Redistribution and use in source and binary forms are permitted provided |
5 | .\" that: (1) source distributions retain this entire copyright notice and | |
6 | .\" comment, and (2) distributions including binaries display the following | |
7 | .\" acknowledgement: ``This product includes software developed by the | |
8 | .\" University of California, Berkeley and its contributors'' in the | |
9 | .\" documentation or other materials provided with the distribution and in | |
10 | .\" all advertising materials mentioning features or use of this software. | |
11 | .\" Neither the name of the University nor the names of its contributors may | |
12 | .\" be used to endorse or promote products derived from this software without | |
13 | .\" specific prior written permission. | |
14 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | |
15 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
16 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
92634ce9 | 17 | .\" |
1c15e888 | 18 | .\" @(#)getrusage.2 6.8 (Berkeley) 6/23/90 |
3031ff5e | 19 | .\" |
1c15e888 | 20 | .TH GETRUSAGE 2 "June 23, 1990" |
3031ff5e KM |
21 | .UC 4 |
22 | .SH NAME | |
852d175d | 23 | getrusage \- get information about resource utilization |
3031ff5e KM |
24 | .SH SYNOPSIS |
25 | .nf | |
852d175d KM |
26 | .ft B |
27 | #include <sys/time.h> | |
28 | #include <sys/resource.h> | |
3031ff5e | 29 | .PP |
852d175d KM |
30 | .ft B |
31 | .ta \w'#define 'u +\w'RUSAGE_CHILDREN 'u +\w'-1 'u | |
32 | #define RUSAGE_SELF 0 /* calling process */ | |
33 | #define RUSAGE_CHILDREN -1 /* terminated child processes */ | |
34 | .DT | |
35 | .PP | |
36 | .ft B | |
37 | getrusage(who, rusage) | |
38 | int who; | |
39 | struct rusage *rusage; | |
3031ff5e KM |
40 | .fi |
41 | .SH DESCRIPTION | |
852d175d KM |
42 | .I Getrusage |
43 | returns information describing the resources utilized by the current | |
44 | process, or all its terminated child processes. | |
45 | The | |
46 | .I who | |
92634ce9 | 47 | parameter is either RUSAGE_SELF or RUSAGE_CHILDREN. |
0b3847f7 | 48 | The buffer to which |
852d175d | 49 | .I rusage |
0b3847f7 | 50 | points will be filled in with |
852d175d | 51 | the following structure: |
3031ff5e | 52 | .PP |
852d175d | 53 | .RS |
92634ce9 KB |
54 | .nf |
55 | struct rusage { | |
852d175d KM |
56 | struct timeval ru_utime; /* user time used */ |
57 | struct timeval ru_stime; /* system time used */ | |
92634ce9 KB |
58 | long ru_maxrss; /* integral max resident set size */ |
59 | long ru_ixrss; /* integral shared text memory size */ | |
60 | long ru_idrss; /* integral unshared data size */ | |
61 | long ru_isrss; /* integral unshared stack size */ | |
62 | long ru_minflt; /* page reclaims */ | |
63 | long ru_majflt; /* page faults */ | |
64 | long ru_nswap; /* swaps */ | |
65 | long ru_inblock; /* block input operations */ | |
66 | long ru_oublock; /* block output operations */ | |
67 | long ru_msgsnd; /* messages sent */ | |
68 | long ru_msgrcv; /* messages received */ | |
69 | long ru_nsignals; /* signals received */ | |
70 | long ru_nvcsw; /* voluntary context switches */ | |
71 | long ru_nivcsw; /* involuntary context switches */ | |
852d175d | 72 | }; |
3031ff5e | 73 | .fi |
92634ce9 | 74 | .RE |
852d175d KM |
75 | .PP |
76 | The fields are interpreted as follows: | |
77 | .TP 15 | |
78 | ru_utime | |
79 | the total amount of time spent executing in user mode. | |
80 | .TP 15 | |
81 | ru_stime | |
82 | the total amount of time spent in the system executing on behalf | |
83 | of the process(es). | |
84 | .TP 15 | |
85 | ru_maxrss | |
86 | the maximum resident set size utilized (in kilobytes). | |
87 | .TP 15 | |
88 | ru_ixrss | |
89 | an \*(lqintegral\*(rq value indicating the amount of memory used | |
0b3847f7 | 90 | by the text segment |
63b0bb9c | 91 | that was also shared among other processes. This value is expressed |
a1fd6e75 | 92 | in units of kilobytes * ticks-of-execution. |
852d175d KM |
93 | .TP 15 |
94 | ru_idrss | |
95 | an integral value of the amount of unshared memory residing in the | |
96 | data segment of a process (expressed in units of | |
a1fd6e75 | 97 | kilobytes * ticks-of-execution). |
852d175d KM |
98 | .TP 15 |
99 | ru_isrss | |
100 | an integral value of the amount of unshared memory residing in the | |
101 | stack segment of a process (expressed in units of | |
a1fd6e75 | 102 | kilobytes * ticks-of-execution). |
852d175d KM |
103 | .TP 15 |
104 | ru_minflt | |
0b3847f7 MK |
105 | the number of page faults serviced without any I/O activity; here |
106 | I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from | |
852d175d KM |
107 | the list of pages awaiting reallocation. |
108 | .TP 15 | |
109 | ru_majflt | |
0b3847f7 | 110 | the number of page faults serviced that required I/O activity. |
852d175d KM |
111 | .TP 15 |
112 | ru_nswap | |
113 | the number of times a process was \*(lqswapped\*(rq out of main | |
114 | memory. | |
115 | .TP 15 | |
116 | ru_inblock | |
117 | the number of times the file system had to perform input. | |
118 | .TP 15 | |
a525da8e | 119 | ru_oublock |
852d175d KM |
120 | the number of times the file system had to perform output. |
121 | .TP 15 | |
122 | ru_msgsnd | |
0b3847f7 | 123 | the number of IPC messages sent. |
852d175d KM |
124 | .TP 15 |
125 | ru_msgrcv | |
0b3847f7 | 126 | the number of IPC messages received. |
852d175d KM |
127 | .TP 15 |
128 | ru_nsignals | |
129 | the number of signals delivered. | |
130 | .TP 15 | |
131 | ru_nvcsw | |
132 | the number of times a context switch resulted due to a process | |
133 | voluntarily giving up the processor before its time slice was | |
134 | completed (usually to await availability of a resource). | |
135 | .TP 15 | |
136 | ru_nivcsw | |
137 | the number of times a context switch resulted due to a higher | |
138 | priority process becoming runnable or because the current process | |
139 | exceeded its time slice. | |
140 | .SH NOTES | |
141 | The numbers | |
142 | .I ru_inblock | |
143 | and | |
a525da8e | 144 | .I ru_oublock |
852d175d | 145 | account only for real |
0b3847f7 | 146 | I/O; data supplied by the caching mechanism is charged only |
852d175d | 147 | to the first process to read or write the data. |
fd690c8b | 148 | .SH ERRORS |
92634ce9 KB |
149 | .I Getrusage |
150 | returns -1 on error. | |
151 | The possible errors are: | |
fd690c8b KM |
152 | .TP 15 |
153 | [EINVAL] | |
154 | The | |
155 | .I who | |
156 | parameter is not a valid value. | |
157 | .TP 15 | |
158 | [EFAULT] | |
159 | The address specified by the | |
160 | .I rusage | |
161 | parameter is not in a valid part of the process address space. | |
852d175d KM |
162 | .SH SEE ALSO |
163 | gettimeofday(2), wait(2) | |
164 | .SH BUGS | |
165 | There is no way to obtain information about a child process | |
63b0bb9c | 166 | that has not yet terminated. |