|
|
1.1 root 1: .\" Copyright (c) 1985 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
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.
17: .\"
18: .\" @(#)getrusage.2 6.8 (Berkeley) 6/23/90
19: .\"
20: .TH GETRUSAGE 2 "June 23, 1990"
21: .UC 4
22: .SH NAME
23: getrusage \- get information about resource utilization
24: .SH SYNOPSIS
25: .nf
26: .ft B
27: #include <sys/time.h>
28: #include <sys/resource.h>
29: .PP
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
37: getrusage(who, rusage)
38: int who;
39: struct rusage *rusage;
40: .fi
41: .SH DESCRIPTION
42: .I Getrusage
43: returns information describing the resources utilized by the current
44: process, or all its terminated child processes.
45: The
46: .I who
47: parameter is either RUSAGE_SELF or RUSAGE_CHILDREN.
48: The buffer to which
49: .I rusage
50: points will be filled in with
51: the following structure:
52: .PP
53: .RS
54: .nf
55: struct rusage {
56: struct timeval ru_utime; /* user time used */
57: struct timeval ru_stime; /* system time used */
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 */
72: };
73: .fi
74: .RE
75: .PP
76: The fields are interpreted as follows:
77: .TP 15
78: ru_utime
79: the total amount of time spent executing in user mode.
80: .TP 15
81: ru_stime
82: the total amount of time spent in the system executing on behalf
83: of the process(es).
84: .TP 15
85: ru_maxrss
86: the maximum resident set size utilized (in kilobytes).
87: .TP 15
88: ru_ixrss
89: an \*(lqintegral\*(rq value indicating the amount of memory used
90: by the text segment
91: that was also shared among other processes. This value is expressed
92: in units of kilobytes * ticks-of-execution.
93: .TP 15
94: ru_idrss
95: an integral value of the amount of unshared memory residing in the
96: data segment of a process (expressed in units of
97: kilobytes * ticks-of-execution).
98: .TP 15
99: ru_isrss
100: an integral value of the amount of unshared memory residing in the
101: stack segment of a process (expressed in units of
102: kilobytes * ticks-of-execution).
103: .TP 15
104: ru_minflt
105: the number of page faults serviced without any I/O activity; here
106: I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from
107: the list of pages awaiting reallocation.
108: .TP 15
109: ru_majflt
110: the number of page faults serviced that required I/O activity.
111: .TP 15
112: ru_nswap
113: the number of times a process was \*(lqswapped\*(rq out of main
114: memory.
115: .TP 15
116: ru_inblock
117: the number of times the file system had to perform input.
118: .TP 15
119: ru_oublock
120: the number of times the file system had to perform output.
121: .TP 15
122: ru_msgsnd
123: the number of IPC messages sent.
124: .TP 15
125: ru_msgrcv
126: the number of IPC messages received.
127: .TP 15
128: ru_nsignals
129: the number of signals delivered.
130: .TP 15
131: ru_nvcsw
132: the number of times a context switch resulted due to a process
133: voluntarily giving up the processor before its time slice was
134: completed (usually to await availability of a resource).
135: .TP 15
136: ru_nivcsw
137: the number of times a context switch resulted due to a higher
138: priority process becoming runnable or because the current process
139: exceeded its time slice.
140: .SH NOTES
141: The numbers
142: .I ru_inblock
143: and
144: .I ru_oublock
145: account only for real
146: I/O; data supplied by the caching mechanism is charged only
147: to the first process to read or write the data.
148: .SH ERRORS
149: .I Getrusage
150: returns -1 on error.
151: The possible errors are:
152: .TP 15
153: [EINVAL]
154: The
155: .I who
156: parameter is not a valid value.
157: .TP 15
158: [EFAULT]
159: The address specified by the
160: .I rusage
161: parameter is not in a valid part of the process address space.
162: .SH SEE ALSO
163: gettimeofday(2), wait(2)
164: .SH BUGS
165: There is no way to obtain information about a child process
166: that has not yet terminated.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.