manual page distributed with 4.2BSD
[unix-history] / usr / src / lib / libc / sys / getrusage.2
CommitLineData
3031ff5e
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
852d175d 5.\" @(#)getrusage.2 5.1 (Berkeley) %G%
3031ff5e 6.\"
852d175d 7.TH GETRUSAGE 2 "18 July 1983"
3031ff5e
KM
8.UC 4
9.SH NAME
852d175d 10getrusage \- get information about resource utilization
3031ff5e
KM
11.SH SYNOPSIS
12.nf
852d175d
KM
13.ft B
14#include <sys/time.h>
15#include <sys/resource.h>
3031ff5e 16.PP
852d175d
KM
17.ft B
18.ta \w'#define 'u +\w'RUSAGE_CHILDREN 'u +\w'-1 'u
19#define RUSAGE_SELF 0 /* calling process */
20#define RUSAGE_CHILDREN -1 /* terminated child processes */
21.DT
22.PP
23.ft B
24getrusage(who, rusage)
25int who;
26struct rusage *rusage;
3031ff5e
KM
27.fi
28.SH DESCRIPTION
852d175d
KM
29.I Getrusage
30returns information describing the resources utilized by the current
31process, or all its terminated child processes.
32The
33.I who
34parameter is one of RUSAGE_SELF and RUSAGE_CHILDREN.
35If
36.I rusage
37is non-zero, the buffer it points to will be filled in with
38the following structure:
3031ff5e
KM
39.PP
40.nf
852d175d
KM
41.RS
42.ta \w'struct 'u +\w'struct 'u +3u*\w'struct 'u
43struct rusage {
44 struct timeval ru_utime; /* user time used */
45 struct timeval ru_stime; /* system time used */
46 int ru_maxrss;
47 int ru_ixrss; /* integral shared memory size */
48 int ru_idrss; /* integral unshared data size */
49 int ru_isrss; /* integral unshared stack size */
50 int ru_minflt; /* page reclaims */
51 int ru_majflt; /* page faults */
52 int ru_nswap; /* swaps */
53 int ru_inblock; /* block input operations */
54 int ru_oublock; /* block output operations */
55 int ru_msgsnd; /* messages sent */
56 int ru_msgrcv; /* messages received */
57 int ru_nsignals; /* signals received */
58 int ru_nvcsw; /* voluntary context switches */
59 int ru_nivcsw; /* involuntary context switches */
60};
61.RE
62.DT
3031ff5e 63.fi
852d175d
KM
64.PP
65The fields are interpreted as follows:
66.TP 15
67ru_utime
68the total amount of time spent executing in user mode.
69.TP 15
70ru_stime
71the total amount of time spent in the system executing on behalf
72of the process(es).
73.TP 15
74ru_maxrss
75the maximum resident set size utilized (in kilobytes).
76.TP 15
77ru_ixrss
78an \*(lqintegral\*(rq value indicating the amount of memory used
79which was also shared among other processes. This value is expressed
80in units of kilobytes * seconds-of-execution and is calculated by
81summing the number of shared memory pages in use each time the internal
82system clock ticks and then averaging over 1 second intervals.
83.TP 15
84ru_idrss
85an integral value of the amount of unshared memory residing in the
86data segment of a process (expressed in units of
87kilobytes * seconds-of-execution).
88.TP 15
89ru_isrss
90an integral value of the amount of unshared memory residing in the
91stack segment of a process (expressed in units of
92kilobytes * seconds-of-execution).
93.TP 15
94ru_minflt
95the number of page faults serviced without any i/o activity; here
96i/o activity is avoided by \*(lqreclaiming\*(rq a page frame from
97the list of pages awaiting reallocation.
98.TP 15
99ru_majflt
100the number of page faults serviced which required i/o activity.
101.TP 15
102ru_nswap
103the number of times a process was \*(lqswapped\*(rq out of main
104memory.
105.TP 15
106ru_inblock
107the number of times the file system had to perform input.
108.TP 15
109ru_outblock
110the number of times the file system had to perform output.
111.TP 15
112ru_msgsnd
113the number of ipc messages sent.
114.TP 15
115ru_msgrcv
116the number of ipc messages received.
117.TP 15
118ru_nsignals
119the number of signals delivered.
120.TP 15
121ru_nvcsw
122the number of times a context switch resulted due to a process
123voluntarily giving up the processor before its time slice was
124completed (usually to await availability of a resource).
125.TP 15
126ru_nivcsw
127the number of times a context switch resulted due to a higher
128priority process becoming runnable or because the current process
129exceeded its time slice.
130.SH NOTES
131The numbers
132.I ru_inblock
133and
134.I ru_outblock
135account only for real
136i/o; data supplied by the cacheing mechanism is charged only
137to the first process to read or write the data.
138.SH SEE ALSO
139gettimeofday(2), wait(2)
140.SH BUGS
141There is no way to obtain information about a child process
142which has not yet terminated.