Fetch maxslp from the kernel. Only use USPACE if it's defined.

This commit is contained in:
matt 2001-07-14 07:09:11 +00:00
parent 68b3b7e9c7
commit 74f8c3cccd
3 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.26 2000/12/01 02:19:43 simonb Exp $ */
/* $NetBSD: extern.h,v 1.27 2001/07/14 07:09:11 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -52,7 +52,7 @@ extern float *dk_mspw;
extern kvm_t *kd;
extern long ntext, textp;
extern int CMDLINE;
extern int hz, stathz;
extern int hz, stathz, maxslp;
extern int naptime, col;
extern int nhosts;
extern int nports;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.28 2000/12/01 02:19:44 simonb Exp $ */
/* $NetBSD: main.c,v 1.29 2001/07/14 07:09:11 matt Exp $ */
/*-
* Copyright (c) 1980, 1992, 1993
@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: main.c,v 1.28 2000/12/01 02:19:44 simonb Exp $");
__RCSID("$NetBSD: main.c,v 1.29 2001/07/14 07:09:11 matt Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -64,6 +64,8 @@ static struct nlist namelist[] = {
{ "_hz" },
#define X_STATHZ 1
{ "_stathz" },
#define X_MAXSLP 2
{ "_maxslp" },
{ "" }
};
static int dellave;
@ -76,7 +78,7 @@ double avenrun[3];
int col;
int naptime = 5;
int verbose = 1; /* to report kvm read errs */
int hz, stathz;
int hz, stathz, maxslp;
char c;
char *namp;
char hostname[MAXHOSTNAMELEN + 1];
@ -217,6 +219,7 @@ main(int argc, char **argv)
hostname[sizeof(hostname) - 1] = '\0';
NREAD(X_HZ, &hz, sizeof hz);
NREAD(X_STATHZ, &stathz, sizeof stathz);
NREAD(X_MAXSLP, &maxslp, sizeof maxslp);
(*curmode->c_init)();
curmode->c_flags |= CF_INIT;
labels();

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.c,v 1.18 2000/12/20 01:17:49 cgd Exp $ */
/* $NetBSD: ps.c,v 1.19 2001/07/14 07:09:11 matt Exp $ */
/*-
* Copyright (c) 1999
@ -45,7 +45,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ps.c,v 1.18 2000/12/20 01:17:49 cgd Exp $");
__RCSID("$NetBSD: ps.c,v 1.19 2001/07/14 07:09:11 matt Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -175,7 +175,7 @@ state2str(struct kinfo_proc *kp)
case SSLEEP:
if (flag & P_SINTR) /* interuptable (long) */
*cp = p->p_slptime >= MAXSLP ? 'I' : 'S';
*cp = p->p_slptime >= maxslp ? 'I' : 'S';
else
*cp = 'D';
break;
@ -303,15 +303,17 @@ pmem2float(struct kinfo_proc *kp)
struct proc *p;
struct eproc *e;
double fracmem;
int szptudot;
int szptudot = 0;
p = &(kp->kp_proc);
e = &(kp->kp_eproc);
if ((p->p_flag & P_INMEM) == 0)
return (0.0);
#ifdef USPACE
/* XXX want pmap ptpages, segtab, etc. (per architecture) */
szptudot = USPACE/getpagesize();
#endif
/* XXX don't have info about shared */
fracmem = ((double)e->e_vm.vm_rssize + szptudot)/mempages;
return (fracmem >= 0) ? 100.0 * fracmem : 0;