summaryrefslogtreecommitdiffstats
path: root/usr.bin/top
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2013-03-11 16:33:05 +0000
committerjhb <jhb@FreeBSD.org>2013-03-11 16:33:05 +0000
commit093e073f6690b9d5a4b46280a09344ee1848a852 (patch)
tree72c3fdf77c3a0ee619fc37a127ed90d9ad3c7dd6 /usr.bin/top
parent5ba861bdf722c3c995a79e124108a7cd5fabffd5 (diff)
downloadFreeBSD-src-093e073f6690b9d5a4b46280a09344ee1848a852.zip
FreeBSD-src-093e073f6690b9d5a4b46280a09344ee1848a852.tar.gz
Fix the 'C' field for a running thread to match the behavior described
in the manpage by having it display the current CPU (ki_oncpu) rather than the previously used CPU (ki_lastcpu). ki_lastcpu is still used for all other thread states. Reported by: Chris Ross <cross+freebsd@distal.com> MFC after: 1 week
Diffstat (limited to 'usr.bin/top')
-rw-r--r--usr.bin/top/machine.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index edfa43a..e01143d 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -797,7 +797,7 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
double pct;
struct handle *hp;
char status[16];
- int state;
+ int cpu, state;
struct rusage ru, *rup;
long p_tot, s_tot;
char *proc_fmt, thr_buf[6], jid_buf[6];
@@ -997,6 +997,13 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
}
/* format this entry */
+ if (smpmode) {
+ if (state == SRUN && pp->ki_oncpu != 0xff)
+ cpu = pp->ki_oncpu;
+ else
+ cpu = pp->ki_lastcpu;
+ } else
+ cpu = 0;
proc_fmt = smpmode ? smp_Proc_format : up_Proc_format;
if (ps.thread != 0)
thr_buf[0] = '\0';
@@ -1014,7 +1021,7 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
format_k2(PROCSIZE(pp)),
format_k2(pagetok(pp->ki_rssize)),
status,
- smpmode ? pp->ki_lastcpu : 0,
+ cpu,
format_time(cputime),
ps.wcpu ? 100.0 * weighted_cpu(pct, pp) : 100.0 * pct,
screen_width > cmdlengthdelta ? screen_width - cmdlengthdelta : 0,
OpenPOWER on IntegriCloud