aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/top
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1999-11-17 03:25:54 +0000
committerBruce Evans <bde@FreeBSD.org>1999-11-17 03:25:54 +0000
commita8224b82fd81665106cb0f76e21755a153c2e5e5 (patch)
tree700adf3d04141c040b3ec75d116b84b097e92b1d /usr.bin/top
parent6b2bdf2c083d4f69ce5c25fb386e926ace4c6d19 (diff)
Notes
Diffstat (limited to 'usr.bin/top')
-rw-r--r--usr.bin/top/machine.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index a3935021d162..cbd44fda445a 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -553,8 +553,7 @@ char *(*get_userid)();
pp = *(hp->next_proc++);
hp->remaining--;
-
- /* get the process's user struct and set cputime */
+ /* get the process's command name */
if ((PP(pp, p_flag) & P_INMEM) == 0) {
/*
* Print swapped processes as <pname>
@@ -570,12 +569,12 @@ char *(*get_userid)();
comm[COMSIZ - 1] = '\0';
}
-#if 0
- /* This does not produce the correct results */
- cputime = PP(pp, p_uticks) + PP(pp, p_sticks) + PP(pp, p_iticks);
-#endif
- /* This does not count interrupts */
- cputime = (PP(pp, p_runtime) / 1000 + 500) / 1000;
+ /*
+ * Convert the process's runtime from microseconds to seconds. This
+ * time includes the interrupt time although that is not wanted here.
+ * ps(1) is similarly sloppy.
+ */
+ cputime = (PP(pp, p_runtime) + 500000) / 1000000;
/* calculate the base for cpu percentages */
pct = pctdouble(PP(pp, p_pctcpu));
@@ -737,7 +736,8 @@ static unsigned char sorted_state[] =
(result = lresult > 0 ? 1 : lresult < 0 ? -1 : 0) == 0)
#define ORDERKEY_CPTICKS \
- if ((result = PP(p2, p_runtime) - PP(p1, p_runtime)) == 0)
+ if ((result = PP(p2, p_runtime) > PP(p1, p_runtime) ? 1 : \
+ PP(p2, p_runtime) < PP(p1, p_runtime) ? -1 : 0) == 0)
#define ORDERKEY_STATE \
if ((result = sorted_state[(unsigned char) PP(p2, p_stat)] - \