=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/systat/vmstat.c,v retrieving revision 1.94 retrieving revision 1.95 diff -c -r1.94 -r1.95 *** src/usr.bin/systat/vmstat.c 2022/02/22 17:35:01 1.94 --- src/usr.bin/systat/vmstat.c 2022/12/04 18:01:57 1.95 *************** *** 1,4 **** ! /* $OpenBSD: vmstat.c,v 1.94 2022/02/22 17:35:01 deraadt Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: vmstat.c,v 1.95 2022/12/04 18:01:57 cheloha Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- *************** *** 98,104 **** int vm_keyboard_callback(int); static time_t t; - static float hertz; static int nintr; static long *intrloc; static char **intrname; --- 98,103 ---- *************** *** 170,176 **** int mib[4], i; size_t size; - hertz = stathz; if (!dkinit(1)) return(0); --- 169,174 ---- *************** *** 323,329 **** Y(fld); \ putint((int)((float)s.fld/etime + 0.5), l, c, w); \ } while (0) - #define MAXFAIL 5 static char cpuchar[] = { '|', '@', '=', '>', ' ' }; static char cpuorder[] = { CP_INTR, CP_SPIN, CP_SYS, CP_USER, CP_IDLE }; --- 321,326 ---- *************** *** 331,363 **** void showkre(void) { float f1, f2; int psiz; u_int64_t inttotal, intcnt; int i, l, c; ! static int failcnt = 0, first_run = 0; double etime; if (state == TIME) { if (!first_run) { first_run = 1; return; } } ! etime = 0; ! for (i = 0; i < CPUSTATES; i++) { X(cpustats.cs_time); - etime += s.cpustats.cs_time[i]; - } - if (etime < 5.0) { /* < 5 ticks - ignore this trash */ - if (failcnt++ >= MAXFAIL) { - error("The alternate system clock has died!"); - failcnt = 0; - } - return; - } - failcnt = 0; - etime /= hertz; inttotal = 0; for (i = 0; i < nintr; i++) { t = intcnt = s.intrcnt[i]; --- 328,354 ---- void showkre(void) { + static struct timespec prev; + struct timespec elapsed, now; float f1, f2; int psiz; u_int64_t inttotal, intcnt; int i, l, c; ! static int first_run = 0; double etime; + clock_gettime(CLOCK_UPTIME, &now); + timespecsub(&now, &prev, &elapsed); + prev = now; if (state == TIME) { if (!first_run) { first_run = 1; return; } } ! etime = elapsed.tv_sec + elapsed.tv_nsec / 1000000000.0; ! for (i = 0; i < CPUSTATES; i++) X(cpustats.cs_time); inttotal = 0; for (i = 0; i < nintr; i++) { t = intcnt = s.intrcnt[i];