Source-Changes-HG archive

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

[src/trunk]: src/bin/ps Retrieve maxslp & uspace from kernel instead of using...



details:   https://anonhg.NetBSD.org/src/rev/a3ebaf075d60
branches:  trunk
changeset: 512706:a3ebaf075d60
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Jul 14 06:53:43 2001 +0000

description:
Retrieve maxslp & uspace from kernel instead of using defines.  Needed for
shared arm code.

diffstat:

 bin/ps/extern.h |   4 ++--
 bin/ps/nlist.c  |  32 ++++++++++++++++++++++++++++++--
 bin/ps/print.c  |   8 ++++----
 3 files changed, 36 insertions(+), 8 deletions(-)

diffs (128 lines):

diff -r 2cc06007abcd -r a3ebaf075d60 bin/ps/extern.h
--- a/bin/ps/extern.h   Sat Jul 14 06:53:23 2001 +0000
+++ b/bin/ps/extern.h   Sat Jul 14 06:53:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.19 2000/06/07 04:57:59 simonb Exp $       */
+/*     $NetBSD: extern.h,v 1.20 2001/07/14 06:53:43 matt Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -41,7 +41,7 @@
 struct varent;
 
 extern double ccpu;
-extern int eval, fscale, mempages, nlistread, rawcpu;
+extern int eval, fscale, mempages, nlistread, rawcpu, maxslp, uspace;
 extern int sumrusage, termwidth, totwidth;
 extern int needenv, needcomm, commandonly, dontuseprocfs, use_procfs;
 extern uid_t myuid;
diff -r 2cc06007abcd -r a3ebaf075d60 bin/ps/nlist.c
--- a/bin/ps/nlist.c    Sat Jul 14 06:53:23 2001 +0000
+++ b/bin/ps/nlist.c    Sat Jul 14 06:53:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nlist.c,v 1.17 2000/06/08 13:30:39 simonb Exp $        */
+/*     $NetBSD: nlist.c,v 1.18 2001/07/14 06:53:44 matt Exp $  */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
 #if 0
 static char sccsid[] = "@(#)nlist.c    8.4 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: nlist.c,v 1.17 2000/06/08 13:30:39 simonb Exp $");
+__RCSID("$NetBSD: nlist.c,v 1.18 2001/07/14 06:53:44 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -102,6 +102,8 @@
 #define        X_CCPU          1
        { "_physmem" },
 #define        X_PHYSMEM       2
+       { "_maxslp" },
+#define        X_MAXSLP        3
        { NULL }
 };
 
@@ -109,6 +111,8 @@
 int    nlistread;                      /* if nlist already read. */
 int    mempages;                       /* number of pages of phys. memory */
 int    fscale;                         /* kernel _fscale variable */
+int    maxslp;                         /* kernel _maxslp variable */
+int    uspace;                         /* kernel USPACE value */
 
 #define kread(x, v) \
        kvm_read(kd, psnl[x].n_value, (char *)&v, sizeof v) != sizeof(v)
@@ -138,6 +142,10 @@
                warnx("ccpu: %s", kvm_geterr(kd));
                eval = rval = 1;
        }
+       if (kread(X_MAXSLP, maxslp)) {
+               warnx("maxslp: %s", kvm_geterr(kd));
+               eval = rval = 1;
+       }
        ccpu = (double)xccpu / fscale;
        return (rval);
 }
@@ -172,6 +180,26 @@
        else
                ccpu = (double)xccpu / fscale;
 
+       mib[0] = CTL_VM;
+       mib[1] = VM_MAXSLP;
+       size = sizeof(maxslp);
+       if (sysctl(mib, 2, &maxslp, &size, NULL, 0) == -1)
+#ifdef MAXSLP
+               maxslp = MAXSLP;
+#else
+               maxslp = 20;            /* XXX Hopefully reasonable default */
+#endif
+
+       mib[0] = CTL_VM;
+       mib[1] = VM_USPACE;
+       size = sizeof(maxslp);
+       if (sysctl(mib, 2, &maxslp, &size, NULL, 0) == -1)
+#ifdef USPACE
+               uspace = USPACE;
+#else
+               uspace = getpagesize(); /* XXX Hopefully reasonable default */
+#endif
+
        return 0;
 }
 
diff -r 2cc06007abcd -r a3ebaf075d60 bin/ps/print.c
--- a/bin/ps/print.c    Sat Jul 14 06:53:23 2001 +0000
+++ b/bin/ps/print.c    Sat Jul 14 06:53:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.65 2001/01/15 21:02:58 christos Exp $      */
+/*     $NetBSD: print.c,v 1.66 2001/07/14 06:53:44 matt Exp $  */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c    8.6 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.65 2001/01/15 21:02:58 christos Exp $");
+__RCSID("$NetBSD: print.c,v 1.66 2001/07/14 06:53:44 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -381,7 +381,7 @@
 
        case SSLEEP:
                if (flag & P_SINTR)     /* interuptable (long) */
-                       *cp = k->p_slptime >= MAXSLP ? 'I' : 'S';
+                       *cp = k->p_slptime >= maxslp ? 'I' : 'S';
                else
                        *cp = 'D';
                break;
@@ -819,7 +819,7 @@
        if ((k->p_flag & P_INMEM) == 0)
                return (0.0);
        /* XXX want pmap ptpages, segtab, etc. (per architecture) */
-       szptudot = USPACE/getpagesize();
+       szptudot = uspace/getpagesize();
        /* XXX don't have info about shared */
        fracmem = ((float)k->p_vm_rssize + szptudot)/mempages;
        return (100.0 * fracmem);



Home | Main Index | Thread Index | Old Index