/* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)kern_proc.c 7.1 (Berkeley) 6/5/86 */ #include "../machine/reg.h" #include "../machine/pte.h" #include "../machine/psl.h" #include "param.h" #include "systm.h" #include "map.h" #include "dir.h" #include "user.h" #include "kernel.h" #include "proc.h" #include "buf.h" #include "inode.h" #include "seg.h" #include "acct.h" #include "wait.h" #include "vm.h" #include "text.h" #include "file.h" #include "quota.h" #include "uio.h" #include "mbuf.h" /* * Clear any pending stops for top and all descendents. */ spgrp(top) struct proc *top; { register struct proc *p; int f = 0; p = top; for (;;) { p->p_sig &= ~(sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU)); f++; /* * If this process has children, descend to them next, * otherwise do any siblings, and if done with this level, * follow back up the tree (but not past top). */ if (p->p_cptr) p = p->p_cptr; else if (p == top) return (f); else if (p->p_osptr) p = p->p_osptr; else for (;;) { p = p->p_pptr; if (p == top) return (f); if (p->p_osptr) { p = p->p_osptr; break; } } } } /* * Is p an inferior of the current process? */ inferior(p) register struct proc *p; { for (; p != u.u_procp; p = p->p_pptr) if (p->p_ppid == 0) return (0); return (1); } struct proc * pfind(pid) int pid; { register struct proc *p; for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash]) if (p->p_pid == pid) 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; }