diff options
author | phk <phk@FreeBSD.org> | 1998-05-28 09:30:28 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-05-28 09:30:28 +0000 |
commit | d3d65c6b2e376ac074f3ca386b6f5b70ea37636f (patch) | |
tree | 6beef0d8c93f6063bf0b9870b87a8c1ef8267cd4 /bin/ps | |
parent | 3654f28d394a609d42e7000c62963c45e3bba3db (diff) | |
download | FreeBSD-src-d3d65c6b2e376ac074f3ca386b6f5b70ea37636f.zip FreeBSD-src-d3d65c6b2e376ac074f3ca386b6f5b70ea37636f.tar.gz |
Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.
Clean up (or if antipodic: down) some of the msgbuf stuff.
Use an inline function rather than a macro for timecounter delta.
Maintain process "on-cpu" time as 64 bits of microseconds to avoid
needless second rollover overhead.
Avoid calling microuptime the second time in mi_switch() if we do
not pass through _idle in cpu_switch()
This should reduce our context-switch overhead a bit, in particular
on pre-P5 and SMP systems.
WARNING: Programs which muck about with struct proc in userland
will have to be fixed.
Reviewed, but found imperfect by: bde
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/print.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index 5d7a0fd..a2b69be 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #endif static const char rcsid[] = - "$Id: print.c,v 1.25 1998/05/15 06:29:16 charnier Exp $"; + "$Id: print.c,v 1.26 1998/05/25 05:07:18 steve Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -446,35 +446,35 @@ cputime(k, ve) VARENT *ve; { VAR *v; + int64_t sec; long secs; long psecs; /* "parts" of a second. first micro, then centi */ char obuff[128]; v = ve->var; if (KI_PROC(k)->p_stat == SZOMB || !k->ki_u.u_valid) { - secs = 0; - psecs = 0; + sec = 0; } else { /* * This counts time spent handling interrupts. We could * fix this, but it is not 100% trivial (and interrupt * time fractions only work on the sparc anyway). XXX */ - secs = KI_PROC(k)->p_rtime.tv_sec; - psecs = KI_PROC(k)->p_rtime.tv_usec; + sec = KI_PROC(k)->p_runtime; if (sumrusage) { - secs += k->ki_u.u_cru.ru_utime.tv_sec + - k->ki_u.u_cru.ru_stime.tv_sec; - psecs += k->ki_u.u_cru.ru_utime.tv_usec + + sec += (k->ki_u.u_cru.ru_utime.tv_sec + + k->ki_u.u_cru.ru_stime.tv_sec) * + (int64_t)1000000; + sec += k->ki_u.u_cru.ru_utime.tv_usec + k->ki_u.u_cru.ru_stime.tv_usec; } - /* - * round and scale to 100's - */ - psecs = (psecs + 5000) / 10000; - secs += psecs / 100; - psecs = psecs % 100; } + /* + * round and scale to 100's + */ + sec = (sec + 5000) / 10000; + secs = sec / 100; + psecs = sec % 100; (void)snprintf(obuff, sizeof(obuff), "%3ld:%02ld.%02ld", secs/60, secs%60, psecs); (void)printf("%*s", v->width, obuff); |