summaryrefslogtreecommitdiffstats
path: root/usr.bin/w
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2000-12-12 07:25:57 +0000
committermckusick <mckusick@FreeBSD.org>2000-12-12 07:25:57 +0000
commitcba301121bc106aaff382428a55f31fef30844e6 (patch)
tree910e5652e5d16d5d0d4e8480f7e386aaf0ca310e /usr.bin/w
parentd577ae457b219ac16b4e152a40ae4d7474c4622f (diff)
downloadFreeBSD-src-cba301121bc106aaff382428a55f31fef30844e6.zip
FreeBSD-src-cba301121bc106aaff382428a55f31fef30844e6.tar.gz
Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather only scalar values and structures that are already part of the kernel/user interface, specifically rusage and rtprio. It no longer contains proc, session, pcred, ucred, procsig, vmspace, pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If any of these changed in size, ps, w, fstat, gcore, systat, and top would all stop working. The new structure has over 200 bytes of unassigned space for future values to be added, yet is nearly 100 bytes smaller per entry than the structure that it replaced.
Diffstat (limited to 'usr.bin/w')
-rw-r--r--usr.bin/w/extern.h6
-rw-r--r--usr.bin/w/proc_compare.c30
-rw-r--r--usr.bin/w/w.c22
3 files changed, 30 insertions, 28 deletions
diff --git a/usr.bin/w/extern.h b/usr.bin/w/extern.h
index 7cb4ed0..7037f9a 100644
--- a/usr.bin/w/extern.h
+++ b/usr.bin/w/extern.h
@@ -31,9 +31,11 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 6/6/93
+ * $FreeBSD$
*/
-struct proc;
+
+struct kinfo_proc;
void pr_attime __P((time_t *, time_t *));
int pr_idle __P((time_t));
-int proc_compare __P((struct proc *, struct proc *));
+int proc_compare __P((struct kinfo_proc *, struct kinfo_proc *));
diff --git a/usr.bin/w/proc_compare.c b/usr.bin/w/proc_compare.c
index e95359c..a94a6b2 100644
--- a/usr.bin/w/proc_compare.c
+++ b/usr.bin/w/proc_compare.c
@@ -32,12 +32,16 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)proc_compare.c 8.2 (Berkeley) 9/23/93";
+#endif
+static const char rcsid[] =
+ "$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/proc.h>
+#include <sys/user.h>
#include "extern.h"
@@ -60,7 +64,7 @@ static char sccsid[] = "@(#)proc_compare.c 8.2 (Berkeley) 9/23/93";
* TODO - consider whether pctcpu should be used.
*/
-#define ISRUN(p) (((p)->p_stat == SRUN) || ((p)->p_stat == SIDL))
+#define ISRUN(p) (((p)->ki_stat == SRUN) || ((p)->ki_stat == SIDL))
#define TESTAB(a, b) ((a)<<1 | (b))
#define ONLYA 2
#define ONLYB 1
@@ -68,7 +72,7 @@ static char sccsid[] = "@(#)proc_compare.c 8.2 (Berkeley) 9/23/93";
int
proc_compare(p1, p2)
- register struct proc *p1, *p2;
+ struct kinfo_proc *p1, *p2;
{
if (p1 == NULL)
@@ -85,36 +89,36 @@ proc_compare(p1, p2)
/*
* tie - favor one with highest recent cpu utilization
*/
- if (p2->p_estcpu > p1->p_estcpu)
+ if (p2->ki_estcpu > p1->ki_estcpu)
return (1);
- if (p1->p_estcpu > p2->p_estcpu)
+ if (p1->ki_estcpu > p2->ki_estcpu)
return (0);
- return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
+ return (p2->ki_pid > p1->ki_pid); /* tie - return highest pid */
}
/*
* weed out zombies
*/
- switch (TESTAB(p1->p_stat == SZOMB, p2->p_stat == SZOMB)) {
+ switch (TESTAB(p1->ki_stat == SZOMB, p2->ki_stat == SZOMB)) {
case ONLYA:
return (1);
case ONLYB:
return (0);
case BOTH:
- return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
+ return (p2->ki_pid > p1->ki_pid); /* tie - return highest pid */
}
/*
* pick the one with the smallest sleep time
*/
- if (p2->p_slptime > p1->p_slptime)
+ if (p2->ki_slptime > p1->ki_slptime)
return (0);
- if (p1->p_slptime > p2->p_slptime)
+ if (p1->ki_slptime > p2->ki_slptime)
return (1);
/*
* favor one sleeping in a non-interruptible sleep
*/
- if (p1->p_flag & P_SINTR && (p2->p_flag & P_SINTR) == 0)
+ if (p1->ki_flag & P_SINTR && (p2->ki_flag & P_SINTR) == 0)
return (1);
- if (p2->p_flag & P_SINTR && (p1->p_flag & P_SINTR) == 0)
+ if (p2->ki_flag & P_SINTR && (p1->ki_flag & P_SINTR) == 0)
return (0);
- return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
+ return (p2->ki_pid > p1->ki_pid); /* tie - return highest pid */
}
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index d91aa8c..0ead030 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -114,7 +114,7 @@ struct entry {
struct kinfo_proc *dkp; /* debug option proc list */
} *ep, *ehead = NULL, **nextp = &ehead;
-#define debugproc(p) *((struct kinfo_proc **)&(p)->kp_eproc.e_spare[0])
+#define debugproc(p) *((struct kinfo_proc **)&(p)->ki_spare[0])
static void pr_header __P((time_t *, int));
static struct stat *ttystat __P((char *, int));
@@ -273,27 +273,23 @@ main(argc, argv)
if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL)
err(1, "%s", kvm_geterr(kd));
for (i = 0; i < nentries; i++, kp++) {
- struct proc *pr = &kp->kp_proc;
- struct eproc *e;
-
- if (pr->p_stat == SIDL || pr->p_stat == SZOMB)
+ if (kp->ki_stat == SIDL || kp->ki_stat == SZOMB)
continue;
- e = &kp->kp_eproc;
for (ep = ehead; ep != NULL; ep = ep->next) {
- if (ep->tdev == e->e_tdev) {
+ if (ep->tdev == kp->ki_tdev) {
/*
* proc is associated with this terminal
*/
- if (ep->kp == NULL && e->e_pgid == e->e_tpgid) {
+ if (ep->kp == NULL && kp->ki_pgid == kp->ki_tpgid) {
/*
* Proc is 'most interesting'
*/
- if (proc_compare(&ep->kp->kp_proc, pr))
+ if (proc_compare(ep->kp, kp))
ep->kp = kp;
}
/*
* Proc debug option info; add to debug
- * list using kinfo_proc kp_eproc.e_spare
+ * list using kinfo_proc ki_spare[0]
* as next pointer; ptr to ptr avoids the
* ptr = long assumption.
*/
@@ -318,7 +314,7 @@ main(argc, argv)
continue;
}
ep->args = fmt_argv(kvm_getargv(kd, ep->kp, argwidth),
- ep->kp->kp_proc.p_comm, MAXCOMLEN);
+ ep->kp->ki_comm, MAXCOMLEN);
if (ep->args == NULL)
err(1, NULL);
}
@@ -389,11 +385,11 @@ main(argc, argv)
char *ptr;
ptr = fmt_argv(kvm_getargv(kd, dkp, argwidth),
- dkp->kp_proc.p_comm, MAXCOMLEN);
+ dkp->ki_comm, MAXCOMLEN);
if (ptr == NULL)
ptr = "-";
(void)printf("\t\t%-9d %s\n",
- dkp->kp_proc.p_pid, ptr);
+ dkp->ki_pid, ptr);
}
}
(void)printf("%-*.*s %-*.*s %-*.*s ",
OpenPOWER on IntegriCloud