summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c51
1 files changed, 12 insertions, 39 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 743128c..c4d5a26 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_fork.c 8.6 (Berkeley) 4/8/94
- * $Id: kern_fork.c,v 1.17 1996/02/23 18:49:17 peter Exp $
+ * $Id: kern_fork.c,v 1.18 1996/03/03 19:48:45 dyson Exp $
*/
#include "opt_ktrace.h"
@@ -195,9 +195,9 @@ retry:
* is in use. Remember the lowest pid that's greater
* than nextpid, so we can avoid checking for a while.
*/
- p2 = (struct proc *)allproc;
+ p2 = allproc.lh_first;
again:
- for (; p2 != NULL; p2 = p2->p_next) {
+ for (; p2 != 0; p2 = p2->p_list.le_next) {
while (p2->p_pid == nextpid ||
p2->p_pgrp->pg_id == nextpid) {
nextpid++;
@@ -212,42 +212,17 @@ again:
}
if (!doingzomb) {
doingzomb = 1;
- p2 = zombproc;
+ p2 = zombproc.lh_first;
goto again;
}
}
-
- /*
- * Link onto allproc (this should probably be delayed).
- * Heavy use of volatile here to prevent the compiler from
- * rearranging code. Yes, it *is* terribly ugly, but at least
- * it works.
- */
p2 = newproc;
-#define Vp2 ((volatile struct proc *)p2)
- Vp2->p_stat = SIDL; /* protect against others */
- Vp2->p_pid = nextpid;
- /*
- * This is really:
- * p2->p_next = allproc;
- * allproc->p_prev = &p2->p_next;
- * p2->p_prev = &allproc;
- * allproc = p2;
- * The assignment via allproc is legal since it is never NULL.
- */
- *(volatile struct proc **)&Vp2->p_next = allproc;
- *(volatile struct proc ***)&allproc->p_prev =
- (volatile struct proc **)&Vp2->p_next;
- *(volatile struct proc ***)&Vp2->p_prev = &allproc;
- allproc = Vp2;
-#undef Vp2
+ p2->p_stat = SIDL; /* protect against others */
+ p2->p_pid = nextpid;
+ LIST_INSERT_HEAD(&allproc, p2, p_list);
p2->p_forw = p2->p_back = NULL; /* shouldn't be necessary */
-
- /* Insert on the hash chain. */
- hash = &pidhash[PIDHASH(p2->p_pid)];
- p2->p_hash = *hash;
- *hash = p2;
+ LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash);
/*
* Make a proc table entry for the new process.
@@ -302,13 +277,11 @@ again:
p2->p_flag |= P_CONTROLT;
if (forktype == ISVFORK)
p2->p_flag |= P_PPWAIT;
- p2->p_pgrpnxt = p1->p_pgrpnxt;
- p1->p_pgrpnxt = p2;
+ LIST_INSERT_AFTER(p1, p2, p_pglist);
p2->p_pptr = p1;
- p2->p_osptr = p1->p_cptr;
- if (p1->p_cptr)
- p1->p_cptr->p_ysptr = p2;
- p1->p_cptr = p2;
+ LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling);
+ LIST_INIT(&p2->p_children);
+
#ifdef KTRACE
/*
* Copy traceflag and tracefile if enabled.
OpenPOWER on IntegriCloud