- Add a new proclist, deadproc, which holds dead-but-not-yet-zombie

processes.
- Create a new data structure, the proclist_desc, which contains a
  pointer to a proclist, and eventually, a pointer to the lock for that
  proclist.  Declare a static array of proclist_descs, proclists[],
  consisting of allproc, deadproc, and zombproc.
This commit is contained in:
thorpej 1998-09-08 23:47:49 +00:00
parent dd07e08538
commit 4edbfb00a8
2 changed files with 41 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.30 1998/09/01 01:02:33 thorpej Exp $ */
/* $NetBSD: kern_proc.c,v 1.31 1998/09/08 23:47:49 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -73,14 +73,29 @@ struct pidhashhead *pidhashtbl;
u_long pidhash;
struct pgrphashhead *pgrphashtbl;
u_long pgrphash;
struct proclist allproc;
struct proclist zombproc;
struct proclist deadproc; /* dead, but not yet undead */
struct proclist zombproc; /* resources have been freed */
struct pool proc_pool;
struct pool pcred_pool;
struct pool plimit_pool;
struct pool pgrp_pool;
struct pool rusage_pool;
/*
* The process list descriptors, used during pid allocation and
* by sysctl. No locking on this data structure is needed since
* it is completely static.
*/
const struct proclist_desc proclists[] = {
{ &allproc },
{ &deadproc },
{ &zombproc },
{ NULL },
};
static void orphanpg __P((struct pgrp *));
#ifdef DEBUG
void pgrpdump __P((void));
@ -92,12 +107,15 @@ void pgrpdump __P((void));
void
procinit()
{
const struct proclist_desc *pd;
for (pd = proclists; pd->pd_list != NULL; pd++)
LIST_INIT(pd->pd_list);
LIST_INIT(&allproc);
LIST_INIT(&zombproc);
pidhashtbl = hashinit(maxproc / 4, M_PROC, M_WAITOK, &pidhash);
pgrphashtbl = hashinit(maxproc / 4, M_PROC, M_WAITOK, &pgrphash);
uihashtbl = hashinit(maxproc / 16, M_PROC, M_WAITOK, &uihash);
pool_init(&proc_pool, sizeof(struct proc), 0, 0, 0, "procpl",
0, pool_page_alloc_nointr, pool_page_free_nointr, M_PROC);
pool_init(&pgrp_pool, sizeof(struct pgrp), 0, 0, 0, "pgrppl",

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.63 1998/09/01 01:02:34 thorpej Exp $ */
/* $NetBSD: proc.h,v 1.64 1998/09/08 23:47:49 thorpej Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -252,6 +252,18 @@ struct pcred {
int p_refcnt; /* Number of references. */
};
LIST_HEAD(proclist, proc); /* a list of processes */
/*
* This structure associates a proclist with its lock.
*/
struct proclist_desc {
struct proclist *pd_list; /* the list */
/*
* XXX Add a pointer to the proclist's lock eventually.
*/
};
#ifdef _KERNEL
/*
* We use process IDs <= PID_MAX; PID_MAX + 1 must also fit in a pid_t,
@ -298,11 +310,14 @@ extern struct proc *curproc; /* Current running proc. */
extern struct proc proc0; /* Process slot for swapper. */
extern int nprocs, maxproc; /* Current and max number of procs. */
LIST_HEAD(proclist, proc);
extern struct proclist allproc; /* List of all processes. */
extern struct proclist deadproc; /* List of dead processes. */
extern struct proclist zombproc; /* List of zombie processes. */
struct proc *initproc; /* Process slots for init, pager. */
extern const struct proclist_desc proclists[];
extern struct pool proc_pool; /* memory pool for procs */
extern struct pool pcred_pool; /* memory pool for pcreds */
extern struct pool plimit_pool; /* memory pool for plimits */
@ -339,7 +354,9 @@ void swapin __P((struct proc *));
int tsleep __P((void *chan, int pri, const char *wmesg, int timo));
void unsleep __P((struct proc *));
void wakeup __P((void *chan));
void reaper __P((void));
void exit1 __P((struct proc *, int));
void exit2 __P((struct proc *));
int fork1 __P((struct proc *, int, register_t *, struct proc **));
void kmeminit __P((void));
void rqinit __P((void));