svn commit: r248167 - head/usr.bin/top
John Baldwin
jhb at FreeBSD.org
Mon Mar 11 16:33:05 UTC 2013
Author: jhb
Date: Mon Mar 11 16:33:05 2013
New Revision: 248167
URL: http://svnweb.freebsd.org/changeset/base/248167
Log:
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 at distal.com>
MFC after: 1 week
Modified:
head/usr.bin/top/machine.c
Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c Mon Mar 11 15:48:17 2013 (r248166)
+++ head/usr.bin/top/machine.c Mon Mar 11 16:33:05 2013 (r248167)
@@ -797,7 +797,7 @@ format_next_process(caddr_t handle, char
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
}
/* 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
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,
More information about the svn-src-head
mailing list