Commit | Line | Data |
---|---|---|
94368568 | 1 | /* kern_proc.c 6.4 84/08/29 */ |
961945a8 SL |
2 | |
3 | #include "../machine/reg.h" | |
4 | #include "../machine/pte.h" | |
5 | #include "../machine/psl.h" | |
29dd101b | 6 | |
94368568 JB |
7 | #include "param.h" |
8 | #include "systm.h" | |
9 | #include "map.h" | |
10 | #include "dir.h" | |
11 | #include "user.h" | |
12 | #include "kernel.h" | |
13 | #include "proc.h" | |
14 | #include "buf.h" | |
15 | #include "inode.h" | |
16 | #include "seg.h" | |
17 | #include "acct.h" | |
18 | #include "wait.h" | |
19 | #include "vm.h" | |
20 | #include "text.h" | |
21 | #include "file.h" | |
22 | #include "quota.h" | |
23 | #include "uio.h" | |
24 | #include "mbuf.h" | |
a1bce776 | 25 | |
4147b3f6 | 26 | spgrp(top, npgrp) |
88a7a62a | 27 | register struct proc *top; |
4147b3f6 BJ |
28 | { |
29 | register struct proc *pp, *p; | |
30 | int f = 0; | |
31 | ||
32 | for (p = top; npgrp == -1 || u.u_uid == p->p_uid || | |
33 | !u.u_uid || inferior(p); p = pp) { | |
34 | if (npgrp == -1) { | |
35 | #define bit(a) (1<<(a-1)) | |
36 | p->p_sig &= ~(bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU)); | |
37 | } else | |
38 | p->p_pgrp = npgrp; | |
39 | f++; | |
40 | /* | |
41 | * Search for children. | |
42 | */ | |
43 | for (pp = proc; pp < procNPROC; pp++) | |
44 | if (pp->p_pptr == p) | |
45 | goto cont; | |
46 | /* | |
47 | * Search for siblings. | |
48 | */ | |
49 | for (; p != top; p = p->p_pptr) | |
50 | for (pp = p + 1; pp < procNPROC; pp++) | |
51 | if (pp->p_pptr == p->p_pptr) | |
52 | goto cont; | |
53 | break; | |
54 | cont: | |
55 | ; | |
56 | } | |
57 | return (f); | |
58 | } | |
59 | ||
29dd101b | 60 | /* |
4147b3f6 | 61 | * Is p an inferior of the current process? |
29dd101b | 62 | */ |
4147b3f6 | 63 | inferior(p) |
a2a2a0d6 | 64 | register struct proc *p; |
29dd101b | 65 | { |
29dd101b | 66 | |
4147b3f6 BJ |
67 | for (; p != u.u_procp; p = p->p_pptr) |
68 | if (p->p_ppid == 0) | |
69 | return (0); | |
70 | return (1); | |
29dd101b | 71 | } |
a2a2a0d6 BJ |
72 | |
73 | struct proc * | |
74 | pfind(pid) | |
75 | int pid; | |
76 | { | |
77 | register struct proc *p; | |
78 | ||
79 | for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash]) | |
80 | if (p->p_pid == pid) | |
81 | return (p); | |
82 | return ((struct proc *)0); | |
83 | } | |
1d348849 MK |
84 | |
85 | /* | |
86 | * init the process queues | |
87 | */ | |
88 | pqinit() | |
89 | { | |
90 | register struct proc *p; | |
91 | ||
92 | /* | |
93 | * most procs are initially on freequeue | |
94 | * nb: we place them there in their "natural" order. | |
95 | */ | |
96 | ||
97 | freeproc = NULL; | |
98 | for (p = procNPROC; --p > proc; freeproc = p) | |
99 | p->p_nxt = freeproc; | |
100 | ||
101 | /* | |
102 | * but proc[0] is special ... | |
103 | */ | |
104 | ||
105 | allproc = p; | |
106 | p->p_nxt = NULL; | |
107 | p->p_prev = &allproc; | |
108 | ||
109 | zombproc = NULL; | |
110 | } |