4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/resource.h>
33 * Backwards compatible vtimes.
36 int vm_utime
; /* user time (60'ths) */
37 int vm_stime
; /* system time (60'ths) */
38 /* divide next two by utime+stime to get averages */
39 unsigned vm_idsrss
; /* integral of d+s rss */
40 unsigned vm_ixrss
; /* integral of text rss */
41 int vm_maxrss
; /* maximum rss */
42 int vm_majflt
; /* major page faults */
43 int vm_minflt
; /* minor page faults */
44 int vm_nswap
; /* number of swaps */
45 int vm_inblk
; /* block reads */
46 int vm_oublk
; /* block writes */
49 static void getvtimes(struct rusage
*, struct vtimes
*);
50 static int scale60(struct timeval
*);
53 vtimes(struct vtimes
*par
, struct vtimes
*chi
)
58 if (getrusage(RUSAGE_SELF
, &ru
) < 0)
63 if (getrusage(RUSAGE_CHILDREN
, &ru
) < 0)
71 getvtimes(struct rusage
*aru
, struct vtimes
*avt
)
74 avt
->vm_utime
= scale60(&aru
->ru_utime
);
75 avt
->vm_stime
= scale60(&aru
->ru_stime
);
76 avt
->vm_idsrss
= ((aru
->ru_idrss
+aru
->ru_isrss
) / 100) * 60;
77 avt
->vm_ixrss
= aru
->ru_ixrss
/ 100 * 60;
78 avt
->vm_maxrss
= aru
->ru_maxrss
;
79 avt
->vm_majflt
= aru
->ru_majflt
;
80 avt
->vm_minflt
= aru
->ru_minflt
;
81 avt
->vm_nswap
= aru
->ru_nswap
;
82 avt
->vm_inblk
= aru
->ru_inblock
;
83 avt
->vm_oublk
= aru
->ru_oublock
;
87 scale60(struct timeval
*tvp
)
90 return (tvp
->tv_sec
* 60 + tvp
->tv_usec
/ 16667);