]>
Commit | Line | Data |
---|---|---|
9bccf70c A |
1 | .\" $NetBSD: getrusage.2,v 1.4 1995/02/27 12:33:23 cgd Exp $ |
2 | .\" | |
3 | .\" Copyright (c) 1985, 1991, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. All advertising materials mentioning features or use of this software | |
15 | .\" must display the following acknowledgement: | |
16 | .\" This product includes software developed by the University of | |
17 | .\" California, Berkeley and its contributors. | |
18 | .\" 4. Neither the name of the University nor the names of its contributors | |
19 | .\" may be used to endorse or promote products derived from this software | |
20 | .\" without specific prior written permission. | |
21 | .\" | |
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | .\" SUCH DAMAGE. | |
33 | .\" | |
34 | .\" @(#)getrusage.2 8.1 (Berkeley) 6/4/93 | |
35 | .\" | |
36 | .Dd June 4, 1993 | |
37 | .Dt GETRUSAGE 2 | |
38 | .Os BSD 4 | |
39 | .Sh NAME | |
40 | .Nm getrusage | |
41 | .Nd get information about resource utilization | |
42 | .Sh SYNOPSIS | |
9bccf70c | 43 | .Fd #include <sys/resource.h> |
2d21ac55 | 44 | .Pp |
9bccf70c A |
45 | .Fd #define RUSAGE_SELF 0 |
46 | .Fd #define RUSAGE_CHILDREN -1 | |
47 | .Ft int | |
2d21ac55 A |
48 | .Fo getrusage |
49 | .Fa "int who" | |
50 | .Fa "struct rusage *r_usage" | |
51 | .Fc | |
9bccf70c A |
52 | .Sh DESCRIPTION |
53 | .Fn Getrusage | |
54 | returns information describing the resources utilized by the current | |
55 | process, or all its terminated child processes. | |
56 | The | |
57 | .Fa who | |
58 | parameter is either | |
59 | .Dv RUSAGE_SELF | |
60 | or | |
61 | .Dv RUSAGE_CHILDREN . | |
62 | The buffer to which | |
2d21ac55 | 63 | .Fa r_usage |
9bccf70c A |
64 | points will be filled in with |
65 | the following structure: | |
66 | .Bd -literal | |
67 | struct rusage { | |
68 | struct timeval ru_utime; /* user time used */ | |
69 | struct timeval ru_stime; /* system time used */ | |
316670eb | 70 | long ru_maxrss; /* max resident set size */ |
9bccf70c A |
71 | long ru_ixrss; /* integral shared text memory size */ |
72 | long ru_idrss; /* integral unshared data size */ | |
73 | long ru_isrss; /* integral unshared stack size */ | |
74 | long ru_minflt; /* page reclaims */ | |
75 | long ru_majflt; /* page faults */ | |
76 | long ru_nswap; /* swaps */ | |
77 | long ru_inblock; /* block input operations */ | |
78 | long ru_oublock; /* block output operations */ | |
79 | long ru_msgsnd; /* messages sent */ | |
80 | long ru_msgrcv; /* messages received */ | |
81 | long ru_nsignals; /* signals received */ | |
82 | long ru_nvcsw; /* voluntary context switches */ | |
83 | long ru_nivcsw; /* involuntary context switches */ | |
84 | }; | |
85 | .Ed | |
86 | .Pp | |
87 | The fields are interpreted as follows: | |
88 | .Bl -tag -width ru_minfltaa | |
89 | .It Fa ru_utime | |
90 | the total amount of time spent executing in user mode. | |
91 | .It Fa ru_stime | |
92 | the total amount of time spent in the system executing on behalf | |
93 | of the process(es). | |
94 | .It Fa ru_maxrss | |
316670eb | 95 | the maximum resident set size utilized (in bytes). |
9bccf70c A |
96 | .It Fa ru_ixrss |
97 | an \*(lqintegral\*(rq value indicating the amount of memory used | |
98 | by the text segment | |
99 | that was also shared among other processes. This value is expressed | |
100 | in units of kilobytes * ticks-of-execution. | |
101 | .It Fa ru_idrss | |
102 | an integral value of the amount of unshared memory residing in the | |
103 | data segment of a process (expressed in units of | |
104 | kilobytes * ticks-of-execution). | |
105 | .It Fa ru_isrss | |
106 | an integral value of the amount of unshared memory residing in the | |
107 | stack segment of a process (expressed in units of | |
108 | kilobytes * ticks-of-execution). | |
109 | .It Fa ru_minflt | |
110 | the number of page faults serviced without any I/O activity; here | |
111 | I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from | |
112 | the list of pages awaiting reallocation. | |
113 | .It Fa ru_majflt | |
114 | the number of page faults serviced that required I/O activity. | |
115 | .It Fa ru_nswap | |
116 | the number of times a process was \*(lqswapped\*(rq out of main | |
117 | memory. | |
118 | .It Fa ru_inblock | |
119 | the number of times the file system had to perform input. | |
120 | .It Fa ru_oublock | |
121 | the number of times the file system had to perform output. | |
122 | .It Fa ru_msgsnd | |
123 | the number of IPC messages sent. | |
124 | .It Fa ru_msgrcv | |
125 | the number of IPC messages received. | |
126 | .It Fa ru_nsignals | |
127 | the number of signals delivered. | |
128 | .It Fa ru_nvcsw | |
129 | the number of times a context switch resulted due to a process | |
130 | voluntarily giving up the processor before its time slice was | |
131 | completed (usually to await availability of a resource). | |
132 | .It Fa ru_nivcsw | |
133 | the number of times a context switch resulted due to a higher | |
134 | priority process becoming runnable or because the current process | |
135 | exceeded its time slice. | |
136 | .El | |
137 | .Sh NOTES | |
138 | The numbers | |
139 | .Fa ru_inblock | |
140 | and | |
141 | .Fa ru_oublock | |
142 | account only for real | |
143 | I/O; data supplied by the caching mechanism is charged only | |
144 | to the first process to read or write the data. | |
2d21ac55 A |
145 | .Sh RETURN VALUES |
146 | .Rv -std getrusage | |
9bccf70c | 147 | .Sh ERRORS |
2d21ac55 A |
148 | The |
149 | .Fn getrusage | |
150 | system call will fail if: | |
9bccf70c | 151 | .Bl -tag -width Er |
2d21ac55 A |
152 | .It Bq Er EFAULT |
153 | The address specified by the | |
154 | .Fa r_usage | |
155 | parameter is not in a valid part of the process address space. | |
9bccf70c A |
156 | .It Bq Er EINVAL |
157 | The | |
158 | .Fa who | |
159 | parameter is not a valid value. | |
9bccf70c | 160 | .El |
2d21ac55 A |
161 | .Sh LEGACY SYNOPSIS |
162 | .Fd #include <sys/time.h> | |
163 | .Fd #include <sys/resource.h> | |
164 | .Pp | |
165 | The include file | |
166 | .In sys/time.h | |
167 | is necessary. | |
9bccf70c A |
168 | .Sh SEE ALSO |
169 | .Xr gettimeofday 2 , | |
2d21ac55 A |
170 | .Xr wait 2 , |
171 | .Xr compat 5 | |
9bccf70c A |
172 | .Sh BUGS |
173 | There is no way to obtain information about a child process | |
174 | that has not yet terminated. | |
175 | .Sh HISTORY | |
176 | The | |
177 | .Fn getrusage | |
178 | function call appeared in | |
179 | .Bx 4.2 . |