BSD 4_3_Reno release
[unix-history] / usr / src / lib / libc / sys / getrusage.2
CommitLineData
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 23getrusage \- 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
37getrusage(who, rusage)
38int who;
39struct rusage *rusage;
3031ff5e
KM
40.fi
41.SH DESCRIPTION
852d175d
KM
42.I Getrusage
43returns information describing the resources utilized by the current
44process, or all its terminated child processes.
45The
46.I who
92634ce9 47parameter is either RUSAGE_SELF or RUSAGE_CHILDREN.
0b3847f7 48The buffer to which
852d175d 49.I rusage
0b3847f7 50points will be filled in with
852d175d 51the following structure:
3031ff5e 52.PP
852d175d 53.RS
92634ce9
KB
54.nf
55struct 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
76The fields are interpreted as follows:
77.TP 15
78ru_utime
79the total amount of time spent executing in user mode.
80.TP 15
81ru_stime
82the total amount of time spent in the system executing on behalf
83of the process(es).
84.TP 15
85ru_maxrss
86the maximum resident set size utilized (in kilobytes).
87.TP 15
88ru_ixrss
89an \*(lqintegral\*(rq value indicating the amount of memory used
0b3847f7 90by the text segment
63b0bb9c 91that was also shared among other processes. This value is expressed
a1fd6e75 92in units of kilobytes * ticks-of-execution.
852d175d
KM
93.TP 15
94ru_idrss
95an integral value of the amount of unshared memory residing in the
96data segment of a process (expressed in units of
a1fd6e75 97kilobytes * ticks-of-execution).
852d175d
KM
98.TP 15
99ru_isrss
100an integral value of the amount of unshared memory residing in the
101stack segment of a process (expressed in units of
a1fd6e75 102kilobytes * ticks-of-execution).
852d175d
KM
103.TP 15
104ru_minflt
0b3847f7
MK
105the number of page faults serviced without any I/O activity; here
106I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from
852d175d
KM
107the list of pages awaiting reallocation.
108.TP 15
109ru_majflt
0b3847f7 110the number of page faults serviced that required I/O activity.
852d175d
KM
111.TP 15
112ru_nswap
113the number of times a process was \*(lqswapped\*(rq out of main
114memory.
115.TP 15
116ru_inblock
117the number of times the file system had to perform input.
118.TP 15
a525da8e 119ru_oublock
852d175d
KM
120the number of times the file system had to perform output.
121.TP 15
122ru_msgsnd
0b3847f7 123the number of IPC messages sent.
852d175d
KM
124.TP 15
125ru_msgrcv
0b3847f7 126the number of IPC messages received.
852d175d
KM
127.TP 15
128ru_nsignals
129the number of signals delivered.
130.TP 15
131ru_nvcsw
132the number of times a context switch resulted due to a process
133voluntarily giving up the processor before its time slice was
134completed (usually to await availability of a resource).
135.TP 15
136ru_nivcsw
137the number of times a context switch resulted due to a higher
138priority process becoming runnable or because the current process
139exceeded its time slice.
140.SH NOTES
141The numbers
142.I ru_inblock
143and
a525da8e 144.I ru_oublock
852d175d 145account only for real
0b3847f7 146I/O; data supplied by the caching mechanism is charged only
852d175d 147to the first process to read or write the data.
fd690c8b 148.SH ERRORS
92634ce9
KB
149.I Getrusage
150returns -1 on error.
151The possible errors are:
fd690c8b
KM
152.TP 15
153[EINVAL]
154The
155.I who
156parameter is not a valid value.
157.TP 15
158[EFAULT]
159The address specified by the
160.I rusage
161parameter is not in a valid part of the process address space.
852d175d
KM
162.SH SEE ALSO
163gettimeofday(2), wait(2)
164.SH BUGS
165There is no way to obtain information about a child process
63b0bb9c 166that has not yet terminated.