Date: Sat, 05 Oct 1996 13:25:32 +0800 From: Peter Wemm <peter@spinner.dialix.com> To: smp@freebsd.org Subject: top patches for smp.. Message-ID: <199610050525.NAA00432@spinner.DIALix.COM>
next in thread | raw e-mail | index | archive | help
If anybody's interested, these patches will show some extra info when top is running. I can't remember if I've send this already.. Hope not. :-) With this, instead of "RUN", you will see either "CPU0/1" or "RUN/1". In this case, "CPU0/1" means that the process is currently on cpu 0, and the "1" is meaningless.. It's set at the same time I just realised. :-] The idea was that you could see the current and "last" cpu, so you had a chance of seeing procs bouncing from one cpu to another, maybe later.. "RUN/1" means it is runnable, waiting in the run queue and last ran on cpu#1. If 'ps' is showing "31Dec69" or "1Jan70", your libkvm is out of sync. I don't know what has changed that caused this BTW. I changed the /sys symlink so I could compile libkvm and top/ps/etc. Index: files/m_freebsd2.c =================================================================== RCS file: /home/ncvs/ports/sysutils/top/files/m_freebsd2.c,v retrieving revision 1.8 diff -u -r1.8 m_freebsd2.c --- m_freebsd2.c 1996/09/28 09:55:32 1.8 +++ m_freebsd2.c 1996/10/04 18:12:34 @@ -523,6 +523,7 @@ register long cputime; register double pct; struct handle *hp; + char runbuf[16]; /* find and remember the next proc structure */ hp = (struct handle *)handle; @@ -555,6 +556,25 @@ /* calculate the base for cpu percentages */ pct = pctdouble(PP(pp, p_pctcpu)); + /* generate "STATE" field */ + switch (PP(pp, p_stat)) { + case SRUN: + if (PP(pp, p_oncpu) >= 0) + sprintf(runbuf, "CPU#%d/%d", PP(pp, p_oncpu), PP(pp, p_lastcpu)) + else + sprintf(runbuf, "RUN/%d", PP(pp, p_lastcpu)); + break; + case SSLEEP: + if (PP(pp, p_wmesg) != NULL) { + sprintf(runbuf, "%.6s", EP(pp, e_wmesg)); + break; + } + /* fall through */ + default: + sprintf(runbuf, "%s", state_abbrev[(unsigned char) PP(pp, p_stat)]); + break; + } + /* format this entry */ sprintf(fmt, Proc_format, @@ -564,9 +584,7 @@ PP(pp, p_nice) - NZERO, format_k(pagetok(PROCSIZE(pp))), format_k(pagetok(VP(pp, vm_rssize))), - ( (PP(pp, p_stat) == SSLEEP) && (PP(pp, p_wmesg) != NULL) ) ? - EP(pp, e_wmesg) : - state_abbrev[(unsigned char) PP(pp, p_stat)], + runbuf, format_time(cputime), 10000.0 * weighted_cpu(pct, pp) / hz, 10000.0 * pct / hz, Cheers, -Peter
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610050525.NAA00432>