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