=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/top/machine.c,v retrieving revision 1.65 retrieving revision 1.66 diff -c -r1.65 -r1.66 *** src/usr.bin/top/machine.c 2010/01/29 00:36:09 1.65 --- src/usr.bin/top/machine.c 2010/03/26 05:10:50 1.66 *************** *** 1,4 **** ! /* $OpenBSD: machine.c,v 1.65 2010/01/29 00:36:09 tedu Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert --- 1,4 ---- ! /* $OpenBSD: machine.c,v 1.66 2010/03/26 05:10:50 lum Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert *************** *** 87,94 **** "", "start", "run", "sleep", "stop", "zomb", "dead", "onproc" }; - static int stathz; - /* these are for calculating cpu state percentages */ static int64_t **cp_time; static int64_t **cp_old; --- 87,92 ---- *************** *** 138,157 **** unsigned int maxslp; - static int - getstathz(void) - { - struct clockinfo cinf; - size_t size = sizeof(cinf); - int mib[2]; - - mib[0] = CTL_KERN; - mib[1] = KERN_CLOCKRATE; - if (sysctl(mib, 2, &cinf, &size, NULL, 0) == -1) - return (-1); - return (cinf.stathz); - } - int machine_init(struct statics *statics) { --- 136,141 ---- *************** *** 179,188 **** err(1, NULL); } - stathz = getstathz(); - if (stathz == -1) - return (-1); - pbase = NULL; pref = NULL; onproc = -1; --- 163,168 ---- *************** *** 471,477 **** pp = *(hp->next_proc++); hp->remaining--; ! cputime = (pp->p_uticks + pp->p_sticks + pp->p_iticks) / stathz; /* calculate the base for cpu percentages */ pct = pctdouble(pp->p_pctcpu); --- 451,457 ---- pp = *(hp->next_proc++); hp->remaining--; ! cputime = pp->p_rtime_sec + ((pp->p_rtime_usec + 500000) / 1000000); /* calculate the base for cpu percentages */ pct = pctdouble(pp->p_pctcpu);