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