Retrieve maxslp & uspace from kernel instead of using defines. Needed for
shared arm code.
This commit is contained in:
parent
84a0bf2b94
commit
68b3b7e9c7
@ -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 var;
|
||||
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;
|
||||
|
@ -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 @@ struct nlist psnl[] = {
|
||||
#define X_CCPU 1
|
||||
{ "_physmem" },
|
||||
#define X_PHYSMEM 2
|
||||
{ "_maxslp" },
|
||||
#define X_MAXSLP 3
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -109,6 +111,8 @@ double ccpu; /* kernel _ccpu variable */
|
||||
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 @@ donlist()
|
||||
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 @@ donlist_sysctl()
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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 @@ state(k, ve, mode)
|
||||
|
||||
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 @@ getpmem(k)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user