1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)vtimes.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include <sys/time.h>
  12: #include <sys/resource.h>
  13: 
  14: /*
  15:  * Backwards compatible vtimes.
  16:  */
  17: struct vtimes {
  18:     int vm_utime;       /* user time (60'ths) */
  19:     int vm_stime;       /* system time (60'ths) */
  20:     /* divide next two by utime+stime to get averages */
  21:     unsigned vm_idsrss;     /* integral of d+s rss */
  22:     unsigned vm_ixrss;      /* integral of text rss */
  23:     int vm_maxrss;      /* maximum rss */
  24:     int vm_majflt;      /* major page faults */
  25:     int vm_minflt;      /* minor page faults */
  26:     int vm_nswap;       /* number of swaps */
  27:     int vm_inblk;       /* block reads */
  28:     int vm_oublk;       /* block writes */
  29: };
  30: 
  31: vtimes(par, chi)
  32:     register struct vtimes *par, *chi;
  33: {
  34:     struct rusage ru;
  35: 
  36:     if (par) {
  37:         if (getrusage(RUSAGE_SELF, &ru) < 0)
  38:             return (-1);
  39:         getvtimes(&ru, par);
  40:     }
  41:     if (chi) {
  42:         if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
  43:             return (-1);
  44:         getvtimes(&ru, chi);
  45:     }
  46:     return (0);
  47: }
  48: 
  49: static
  50: getvtimes(aru, avt)
  51:     register struct rusage *aru;
  52:     register struct vtimes *avt;
  53: {
  54: 
  55:     avt->vm_utime = scale60(&aru->ru_utime);
  56:     avt->vm_stime = scale60(&aru->ru_stime);
  57:     avt->vm_idsrss = ((aru->ru_idrss+aru->ru_isrss) / 100) * 60;
  58:     avt->vm_ixrss = aru->ru_ixrss / 100 * 60;
  59:     avt->vm_maxrss = aru->ru_maxrss;
  60:     avt->vm_majflt = aru->ru_majflt;
  61:     avt->vm_minflt = aru->ru_minflt;
  62:     avt->vm_nswap = aru->ru_nswap;
  63:     avt->vm_inblk = aru->ru_inblock;
  64:     avt->vm_oublk = aru->ru_oublock;
  65: }
  66: 
  67: static
  68: scale60(tvp)
  69:     register struct timeval *tvp;
  70: {
  71: 
  72:     return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
  73: }

Defined functions

getvtimes defined in line 49; used 2 times
scale60 defined in line 67; used 2 times
vtimes defined in line 31; used 3 times

Defined variables

sccsid defined in line 8; never used

Defined struct's

vtimes defined in line 17; used 4 times
  • in line 32(2), 52(2)
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: ?E00
Valid CSS Valid XHTML 1.0 Strict