linked lists of active, zombie and free procs; avoid linear proc
[unix-history] / usr / src / sys / kern / kern_proc.c
index 88bdebb..1584eb8 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_proc.c     6.1     83/07/29        */
+/*     kern_proc.c     6.2     84/05/22        */
 
 #include "../machine/reg.h"
 #include "../machine/pte.h"
 
 #include "../machine/reg.h"
 #include "../machine/pte.h"
@@ -82,3 +82,30 @@ pfind(pid)
                        return (p);
        return ((struct proc *)0);
 }
                        return (p);
        return ((struct proc *)0);
 }
+
+/*
+ * init the process queues
+ */
+pqinit()
+{
+       register struct proc *p;
+
+       /*
+        * most procs are initially on freequeue
+        *      nb: we place them there in their "natural" order.
+        */
+
+       freeproc = NULL;
+       for (p = procNPROC; --p > proc; freeproc = p)
+               p->p_nxt = freeproc;
+
+       /*
+        * but proc[0] is special ...
+        */
+
+       allproc = p;
+       p->p_nxt = NULL;
+       p->p_prev = &allproc;
+
+       zombproc = NULL;
+}