Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.bin/top/machine Pull up revisions 1.10, 1.12-1.13 (r...



details:   https://anonhg.NetBSD.org/src/rev/950f44e83e91
branches:  netbsd-1-5
changeset: 492743:950f44e83e91
user:      he <he%NetBSD.org@localhost>
date:      Sat Feb 09 19:56:24 2002 +0000

description:
Pull up revisions 1.10,1.12-1.13 (requested by pooka):
  Display wait channels for sleeping processes.

diffstat:

 usr.bin/top/machine/m_netbsd15.c |  44 ++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 10 deletions(-)

diffs (94 lines):

diff -r bab473a00bf1 -r 950f44e83e91 usr.bin/top/machine/m_netbsd15.c
--- a/usr.bin/top/machine/m_netbsd15.c  Sat Feb 09 19:50:24 2002 +0000
+++ b/usr.bin/top/machine/m_netbsd15.c  Sat Feb 09 19:56:24 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: m_netbsd15.c,v 1.7.2.1 2001/05/26 15:35:22 he Exp $    */
+/*     $NetBSD: m_netbsd15.c,v 1.7.2.2 2002/02/09 19:56:24 he Exp $    */
 
 /*
  * top - a top users display for Unix
@@ -34,7 +34,7 @@
  *             Simon Burge <simonb%netbsd.org@localhost>
  *
  *
- * $Id: m_netbsd15.c,v 1.7.2.1 2001/05/26 15:35:22 he Exp $
+ * $Id: m_netbsd15.c,v 1.7.2.2 2002/02/09 19:56:24 he Exp $
  */
 
 #include <sys/param.h>
@@ -85,21 +85,20 @@
  */
 
 static char header[] =
-  "  PID X        PRI NICE   SIZE   RES STATE     TIME   WCPU    CPU COMMAND";
+  "  PID X        PRI NICE   SIZE   RES STATE      TIME   WCPU    CPU COMMAND";
 /* 0123456   -- field to fill in starts at header+6 */
 #define UNAME_START 6
 
 #define Proc_format \
-       "%5d %-8.8s %3d %4d%7s %5s %-7s%7s %5.2f%% %5.2f%% %.12s"
+       "%5d %-8.8s %3d %4d%7s %5s %-8.8s%7s %5.2f%% %5.2f%% %.12s"
 
 
-/* Process state names for the "STATE" column of the display.
- * The extra nulls in the string "run" are for adding a slash and
- * the processor number when needed.
+/* 
+ * Process state names for the "STATE" column of the display.
  */
 
-char *state_abbrev[] = {
-       "", "start", "run\0\0\0", "sleep", "stop", "zomb", "dead", "onproc"
+const char *state_abbrev[] = {
+       "", "START", "RUN", "SLEEP", "STOP", "ZOMB", "DEAD", "CPU"
 };
 
 static kvm_t *kd;
@@ -448,6 +447,11 @@
        long cputime;
        double pct;
        struct handle *hp;
+       const char *statep;
+#ifdef KI_NOCPU
+       char state[10];
+#endif
+       char wmesg[KI_WMESGLEN + 1];
        static char fmt[128];           /* static area where result is built */
 
        /* find and remember the next proc structure */
@@ -481,6 +485,26 @@
        /* calculate the base for cpu percentages */
        pct = pctdouble(pp->p_pctcpu);
 
+       if (pp->p_stat == SSLEEP) {
+               strlcpy(wmesg, pp->p_wmesg, sizeof(wmesg));
+               statep = wmesg;
+       } else
+               statep = state_abbrev[(unsigned)pp->p_stat];
+
+#ifdef KI_NOCPU
+       /* Post-1.5 change: add cpu number if appropriate */
+       if (pp->p_cpuid != KI_NOCPU) {
+               switch (pp->p_stat) {
+               case SONPROC:
+               case SRUN:
+               case SSLEEP:                    
+                       snprintf(state, sizeof(state), "%.6s/%lld", 
+                                statep, (long long)pp->p_cpuid);
+                       statep = state;
+                       break;
+               }
+       }
+#endif
        /* format this entry */
        sprintf(fmt,
            Proc_format,
@@ -490,7 +514,7 @@
            pp->p_nice - NZERO,
            format_k(pagetok(PROCSIZE(pp))),
            format_k(pagetok(pp->p_vm_rssize)),
-           state_abbrev[(unsigned char) pp->p_stat],
+           statep,
            format_time(cputime),
            100.0 * weighted_cpu(pct, pp),
            100.0 * pct,



Home | Main Index | Thread Index | Old Index