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