| @@ -1,565 +1,567 @@ | | | @@ -1,565 +1,567 @@ |
1 | /* $NetBSD: proc.h,v 1.307 2011/05/02 22:27:53 rmind Exp $ */ | | 1 | /* $NetBSD: proc.h,v 1.308 2011/07/27 13:20:07 uebayasi Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /*- | | 32 | /*- |
33 | * Copyright (c) 1986, 1989, 1991, 1993 | | 33 | * Copyright (c) 1986, 1989, 1991, 1993 |
34 | * The Regents of the University of California. All rights reserved. | | 34 | * The Regents of the University of California. All rights reserved. |
35 | * (c) UNIX System Laboratories, Inc. | | 35 | * (c) UNIX System Laboratories, Inc. |
36 | * All or some portions of this file are derived from material licensed | | 36 | * All or some portions of this file are derived from material licensed |
37 | * to the University of California by American Telephone and Telegraph | | 37 | * to the University of California by American Telephone and Telegraph |
38 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | | 38 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with |
39 | * the permission of UNIX System Laboratories, Inc. | | 39 | * the permission of UNIX System Laboratories, Inc. |
40 | * | | 40 | * |
41 | * Redistribution and use in source and binary forms, with or without | | 41 | * Redistribution and use in source and binary forms, with or without |
42 | * modification, are permitted provided that the following conditions | | 42 | * modification, are permitted provided that the following conditions |
43 | * are met: | | 43 | * are met: |
44 | * 1. Redistributions of source code must retain the above copyright | | 44 | * 1. Redistributions of source code must retain the above copyright |
45 | * notice, this list of conditions and the following disclaimer. | | 45 | * notice, this list of conditions and the following disclaimer. |
46 | * 2. Redistributions in binary form must reproduce the above copyright | | 46 | * 2. Redistributions in binary form must reproduce the above copyright |
47 | * notice, this list of conditions and the following disclaimer in the | | 47 | * notice, this list of conditions and the following disclaimer in the |
48 | * documentation and/or other materials provided with the distribution. | | 48 | * documentation and/or other materials provided with the distribution. |
49 | * 3. Neither the name of the University nor the names of its contributors | | 49 | * 3. Neither the name of the University nor the names of its contributors |
50 | * may be used to endorse or promote products derived from this software | | 50 | * may be used to endorse or promote products derived from this software |
51 | * without specific prior written permission. | | 51 | * without specific prior written permission. |
52 | * | | 52 | * |
53 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 53 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
54 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 54 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
55 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 55 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
63 | * SUCH DAMAGE. | | 63 | * SUCH DAMAGE. |
64 | * | | 64 | * |
65 | * @(#)proc.h 8.15 (Berkeley) 5/19/95 | | 65 | * @(#)proc.h 8.15 (Berkeley) 5/19/95 |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | #ifndef _SYS_PROC_H_ | | 68 | #ifndef _SYS_PROC_H_ |
69 | #define _SYS_PROC_H_ | | 69 | #define _SYS_PROC_H_ |
70 | | | 70 | |
71 | #if defined(_KERNEL_OPT) | | 71 | #if defined(_KERNEL_OPT) |
72 | #include "opt_multiprocessor.h" | | 72 | #include "opt_multiprocessor.h" |
73 | #include "opt_kstack.h" | | 73 | #include "opt_kstack.h" |
74 | #include "opt_lockdebug.h" | | 74 | #include "opt_lockdebug.h" |
75 | #endif | | 75 | #endif |
76 | | | 76 | |
77 | #include <machine/proc.h> /* Machine-dependent proc substruct */ | | 77 | #include <machine/proc.h> /* Machine-dependent proc substruct */ |
78 | #include <sys/aio.h> | | 78 | #include <sys/aio.h> |
79 | #include <sys/rwlock.h> | | 79 | #include <sys/rwlock.h> |
80 | #include <sys/mqueue.h> | | 80 | #include <sys/mqueue.h> |
81 | #include <sys/mutex.h> | | 81 | #include <sys/mutex.h> |
82 | #include <sys/condvar.h> | | 82 | #include <sys/condvar.h> |
83 | #include <sys/lwp.h> | | 83 | #include <sys/lwp.h> |
84 | #include <sys/queue.h> | | 84 | #include <sys/queue.h> |
85 | #include <sys/signalvar.h> | | 85 | #include <sys/signalvar.h> |
86 | #include <sys/siginfo.h> | | 86 | #include <sys/siginfo.h> |
87 | #include <sys/event.h> | | 87 | #include <sys/event.h> |
88 | #include <sys/specificdata.h> | | 88 | #include <sys/specificdata.h> |
89 | | | 89 | |
90 | #ifndef _KERNEL | | 90 | #ifndef _KERNEL |
91 | #include <sys/time.h> | | 91 | #include <sys/time.h> |
92 | #include <sys/resource.h> | | 92 | #include <sys/resource.h> |
93 | #endif | | 93 | #endif |
94 | | | 94 | |
95 | /* | | 95 | /* |
96 | * One structure allocated per session. | | 96 | * One structure allocated per session. |
97 | */ | | 97 | */ |
98 | struct session { | | 98 | struct session { |
99 | int s_count; /* Ref cnt; pgrps in session */ | | 99 | int s_count; /* Ref cnt; pgrps in session */ |
100 | u_int s_flags; | | 100 | u_int s_flags; |
101 | #define S_LOGIN_SET 1 /* s_login set in this session */ | | 101 | #define S_LOGIN_SET 1 /* s_login set in this session */ |
102 | struct proc *s_leader; /* Session leader */ | | 102 | struct proc *s_leader; /* Session leader */ |
103 | struct vnode *s_ttyvp; /* Vnode of controlling terminal */ | | 103 | struct vnode *s_ttyvp; /* Vnode of controlling terminal */ |
104 | struct tty *s_ttyp; /* Controlling terminal */ | | 104 | struct tty *s_ttyp; /* Controlling terminal */ |
105 | char s_login[MAXLOGNAME]; /* Setlogin() name */ | | 105 | char s_login[MAXLOGNAME]; /* Setlogin() name */ |
106 | pid_t s_sid; /* Session ID (pid of leader) */ | | 106 | pid_t s_sid; /* Session ID (pid of leader) */ |
107 | }; | | 107 | }; |
108 | | | 108 | |
109 | /* | | 109 | /* |
110 | * One structure allocated per process group. | | 110 | * One structure allocated per process group. |
111 | */ | | 111 | */ |
112 | struct pgrp { | | 112 | struct pgrp { |
113 | LIST_HEAD(, proc) pg_members; /* Pointer to pgrp members */ | | 113 | LIST_HEAD(, proc) pg_members; /* Pointer to pgrp members */ |
114 | struct session *pg_session; /* Pointer to session */ | | 114 | struct session *pg_session; /* Pointer to session */ |
115 | pid_t pg_id; /* Pgrp id */ | | 115 | pid_t pg_id; /* Pgrp id */ |
116 | int pg_jobc; /* | | 116 | int pg_jobc; /* |
117 | * Number of processes qualifying | | 117 | * Number of processes qualifying |
118 | * pgrp for job control | | 118 | * pgrp for job control |
119 | */ | | 119 | */ |
120 | }; | | 120 | }; |
121 | | | 121 | |
122 | /* | | 122 | /* |
123 | * One structure allocated per emulation. | | 123 | * One structure allocated per emulation. |
124 | */ | | 124 | */ |
125 | struct exec_package; | | 125 | struct exec_package; |
126 | struct ras; | | 126 | struct ras; |
127 | struct kauth_cred; | | 127 | struct kauth_cred; |
128 | | | 128 | |
129 | struct emul { | | 129 | struct emul { |
130 | const char *e_name; /* Symbolic name */ | | 130 | const char *e_name; /* Symbolic name */ |
131 | const char *e_path; /* Extra emulation path (NULL if none)*/ | | 131 | const char *e_path; /* Extra emulation path (NULL if none)*/ |
132 | #ifndef __HAVE_MINIMAL_EMUL | | 132 | #ifndef __HAVE_MINIMAL_EMUL |
133 | int e_flags; /* Miscellaneous flags, see above */ | | 133 | int e_flags; /* Miscellaneous flags, see above */ |
134 | /* Syscall handling function */ | | 134 | /* Syscall handling function */ |
135 | const int *e_errno; /* Errno array */ | | 135 | const int *e_errno; /* Errno array */ |
136 | int e_nosys; /* Offset of the nosys() syscall */ | | 136 | int e_nosys; /* Offset of the nosys() syscall */ |
137 | int e_nsysent; /* Number of system call entries */ | | 137 | int e_nsysent; /* Number of system call entries */ |
138 | #endif | | 138 | #endif |
139 | struct sysent *e_sysent; /* System call array */ | | 139 | struct sysent *e_sysent; /* System call array */ |
140 | const char * const *e_syscallnames; /* System call name array */ | | 140 | const char * const *e_syscallnames; /* System call name array */ |
141 | /* Signal sending function */ | | 141 | /* Signal sending function */ |
142 | void (*e_sendsig)(const struct ksiginfo *, | | 142 | void (*e_sendsig)(const struct ksiginfo *, |
143 | const sigset_t *); | | 143 | const sigset_t *); |
144 | void (*e_trapsignal)(struct lwp *, struct ksiginfo *); | | 144 | void (*e_trapsignal)(struct lwp *, struct ksiginfo *); |
145 | int (*e_tracesig)(struct proc *, int); | | 145 | int (*e_tracesig)(struct proc *, int); |
146 | char *e_sigcode; /* Start of sigcode */ | | 146 | char *e_sigcode; /* Start of sigcode */ |
147 | char *e_esigcode; /* End of sigcode */ | | 147 | char *e_esigcode; /* End of sigcode */ |
148 | /* Set registers before execution */ | | 148 | /* Set registers before execution */ |
149 | struct uvm_object **e_sigobject;/* shared sigcode object */ | | 149 | struct uvm_object **e_sigobject;/* shared sigcode object */ |
150 | void (*e_setregs)(struct lwp *, struct exec_package *, | | 150 | void (*e_setregs)(struct lwp *, struct exec_package *, |
151 | vaddr_t); | | 151 | vaddr_t); |
152 | | | 152 | |
153 | /* Per-process hooks */ | | 153 | /* Per-process hooks */ |
154 | void (*e_proc_exec)(struct proc *, struct exec_package *); | | 154 | void (*e_proc_exec)(struct proc *, struct exec_package *); |
155 | void (*e_proc_fork)(struct proc *, struct lwp *, int); | | 155 | void (*e_proc_fork)(struct proc *, struct lwp *, int); |
156 | void (*e_proc_exit)(struct proc *); | | 156 | void (*e_proc_exit)(struct proc *); |
157 | void (*e_lwp_fork)(struct lwp *, struct lwp *); | | 157 | void (*e_lwp_fork)(struct lwp *, struct lwp *); |
158 | void (*e_lwp_exit)(struct lwp *); | | 158 | void (*e_lwp_exit)(struct lwp *); |
159 | | | 159 | |
160 | #ifdef __HAVE_SYSCALL_INTERN | | 160 | #ifdef __HAVE_SYSCALL_INTERN |
161 | void (*e_syscall_intern)(struct proc *); | | 161 | void (*e_syscall_intern)(struct proc *); |
162 | #else | | 162 | #else |
163 | void (*e_syscall)(void); | | 163 | void (*e_syscall)(void); |
164 | #endif | | 164 | #endif |
165 | /* Emulation specific sysctl data */ | | 165 | /* Emulation specific sysctl data */ |
166 | struct sysctlnode *e_sysctlovly; | | 166 | struct sysctlnode *e_sysctlovly; |
167 | int (*e_fault)(struct proc *, vaddr_t, int); | | 167 | int (*e_fault)(struct proc *, vaddr_t, int); |
168 | | | 168 | |
169 | vaddr_t (*e_vm_default_addr)(struct proc *, vaddr_t, vsize_t); | | 169 | vaddr_t (*e_vm_default_addr)(struct proc *, vaddr_t, vsize_t); |
170 | | | 170 | |
171 | /* Emulation-specific hook for userspace page faults */ | | 171 | /* Emulation-specific hook for userspace page faults */ |
172 | int (*e_usertrap)(struct lwp *, vaddr_t, void *); | | 172 | int (*e_usertrap)(struct lwp *, vaddr_t, void *); |
173 | | | 173 | |
174 | /* SA-related information */ | | 174 | /* SA-related information */ |
175 | const struct sa_emul *e_sa; | | 175 | const struct sa_emul *e_sa; |
176 | | | 176 | |
177 | size_t e_ucsize; /* size of ucontext_t */ | | 177 | size_t e_ucsize; /* size of ucontext_t */ |
178 | void (*e_startlwp)(void *); | | 178 | void (*e_startlwp)(void *); |
179 | }; | | 179 | }; |
180 | | | 180 | |
181 | /* | | 181 | /* |
182 | * Emulation miscelaneous flags | | 182 | * Emulation miscelaneous flags |
183 | */ | | 183 | */ |
184 | #define EMUL_HAS_SYS___syscall 0x001 /* Has SYS___syscall */ | | 184 | #define EMUL_HAS_SYS___syscall 0x001 /* Has SYS___syscall */ |
185 | | | 185 | |
186 | /* | | 186 | /* |
187 | * Description of a process. | | 187 | * Description of a process. |
188 | * | | 188 | * |
189 | * This structure contains the information needed to manage a thread of | | 189 | * This structure contains the information needed to manage a thread of |
190 | * control, known in UN*X as a process; it has references to substructures | | 190 | * control, known in UN*X as a process; it has references to substructures |
191 | * containing descriptions of things that the process uses, but may share | | 191 | * containing descriptions of things that the process uses, but may share |
192 | * with related processes. The process structure and the substructures | | 192 | * with related processes. The process structure and the substructures |
193 | * are always addressible except for those marked "(PROC ONLY)" below, | | 193 | * are always addressible except for those marked "(PROC ONLY)" below, |
194 | * which might be addressible only on a processor on which the process | | 194 | * which might be addressible only on a processor on which the process |
195 | * is running. | | 195 | * is running. |
196 | * | | 196 | * |
197 | * Field markings and the corresponding locks: | | 197 | * Field markings and the corresponding locks: |
198 | * | | 198 | * |
199 | * a: p_auxlock | | 199 | * a: p_auxlock |
200 | * k: ktrace_mutex | | 200 | * k: ktrace_mutex |
201 | * l: proc_lock | | 201 | * l: proc_lock |
202 | * t: p_stmutex | | 202 | * t: p_stmutex |
203 | * p: p_lock | | 203 | * p: p_lock |
204 | * (: updated atomically | | 204 | * (: updated atomically |
205 | * :: unlocked, stable | | 205 | * :: unlocked, stable |
206 | */ | | 206 | */ |
| | | 207 | struct vmspace; |
| | | 208 | |
207 | struct proc { | | 209 | struct proc { |
208 | LIST_ENTRY(proc) p_list; /* l: List of all processes */ | | 210 | LIST_ENTRY(proc) p_list; /* l: List of all processes */ |
209 | | | 211 | |
210 | kmutex_t p_auxlock; /* :: secondary, longer term lock */ | | 212 | kmutex_t p_auxlock; /* :: secondary, longer term lock */ |
211 | kmutex_t *p_lock; /* :: general mutex */ | | 213 | kmutex_t *p_lock; /* :: general mutex */ |
212 | kmutex_t p_stmutex; /* :: mutex on profiling state */ | | 214 | kmutex_t p_stmutex; /* :: mutex on profiling state */ |
213 | krwlock_t p_reflock; /* p: lock for debugger, procfs */ | | 215 | krwlock_t p_reflock; /* p: lock for debugger, procfs */ |
214 | kcondvar_t p_waitcv; /* p: wait, stop CV on children */ | | 216 | kcondvar_t p_waitcv; /* p: wait, stop CV on children */ |
215 | kcondvar_t p_lwpcv; /* p: wait, stop CV on LWPs */ | | 217 | kcondvar_t p_lwpcv; /* p: wait, stop CV on LWPs */ |
216 | | | 218 | |
217 | /* Substructures: */ | | 219 | /* Substructures: */ |
218 | struct kauth_cred *p_cred; /* p: Master copy of credentials */ | | 220 | struct kauth_cred *p_cred; /* p: Master copy of credentials */ |
219 | struct filedesc *p_fd; /* :: Ptr to open files structure */ | | 221 | struct filedesc *p_fd; /* :: Ptr to open files structure */ |
220 | struct cwdinfo *p_cwdi; /* :: cdir/rdir/cmask info */ | | 222 | struct cwdinfo *p_cwdi; /* :: cdir/rdir/cmask info */ |
221 | struct pstats *p_stats; /* :: Accounting/stats (PROC ONLY) */ | | 223 | struct pstats *p_stats; /* :: Accounting/stats (PROC ONLY) */ |
222 | struct plimit *p_limit; /* :: Process limits */ | | 224 | struct plimit *p_limit; /* :: Process limits */ |
223 | struct vmspace *p_vmspace; /* :: Address space */ | | 225 | struct vmspace *p_vmspace; /* :: Address space */ |
224 | struct sigacts *p_sigacts; /* :: Process sigactions */ | | 226 | struct sigacts *p_sigacts; /* :: Process sigactions */ |
225 | struct aioproc *p_aio; /* p: Asynchronous I/O data */ | | 227 | struct aioproc *p_aio; /* p: Asynchronous I/O data */ |
226 | u_int p_mqueue_cnt; /* (: Count of open message queues */ | | 228 | u_int p_mqueue_cnt; /* (: Count of open message queues */ |
227 | specificdata_reference | | 229 | specificdata_reference |
228 | p_specdataref; /* subsystem proc-specific data */ | | 230 | p_specdataref; /* subsystem proc-specific data */ |
229 | | | 231 | |
230 | int p_exitsig; /* l: signal to send to parent on exit */ | | 232 | int p_exitsig; /* l: signal to send to parent on exit */ |
231 | int p_flag; /* p: PK_* flags */ | | 233 | int p_flag; /* p: PK_* flags */ |
232 | int p_sflag; /* p: PS_* flags */ | | 234 | int p_sflag; /* p: PS_* flags */ |
233 | int p_slflag; /* s, l: PSL_* flags */ | | 235 | int p_slflag; /* s, l: PSL_* flags */ |
234 | int p_lflag; /* l: PL_* flags */ | | 236 | int p_lflag; /* l: PL_* flags */ |
235 | int p_stflag; /* t: PST_* flags */ | | 237 | int p_stflag; /* t: PST_* flags */ |
236 | char p_stat; /* p: S* process status. */ | | 238 | char p_stat; /* p: S* process status. */ |
237 | char p_trace_enabled;/* p: cached by syscall_intern() */ | | 239 | char p_trace_enabled;/* p: cached by syscall_intern() */ |
238 | char p_pad1[2]; /* unused */ | | 240 | char p_pad1[2]; /* unused */ |
239 | | | 241 | |
240 | pid_t p_pid; /* :: Process identifier. */ | | 242 | pid_t p_pid; /* :: Process identifier. */ |
241 | LIST_ENTRY(proc) p_pglist; /* l: List of processes in pgrp. */ | | 243 | LIST_ENTRY(proc) p_pglist; /* l: List of processes in pgrp. */ |
242 | struct proc *p_pptr; /* l: Pointer to parent process. */ | | 244 | struct proc *p_pptr; /* l: Pointer to parent process. */ |
243 | LIST_ENTRY(proc) p_sibling; /* l: List of sibling processes. */ | | 245 | LIST_ENTRY(proc) p_sibling; /* l: List of sibling processes. */ |
244 | LIST_HEAD(, proc) p_children; /* l: List of children. */ | | 246 | LIST_HEAD(, proc) p_children; /* l: List of children. */ |
245 | LIST_HEAD(, lwp) p_lwps; /* p: List of LWPs. */ | | 247 | LIST_HEAD(, lwp) p_lwps; /* p: List of LWPs. */ |
246 | struct ras *p_raslist; /* a: List of RAS entries */ | | 248 | struct ras *p_raslist; /* a: List of RAS entries */ |
247 | | | 249 | |
248 | /* The following fields are all zeroed upon creation in fork. */ | | 250 | /* The following fields are all zeroed upon creation in fork. */ |
249 | #define p_startzero p_nlwps | | 251 | #define p_startzero p_nlwps |
250 | | | 252 | |
251 | int p_nlwps; /* p: Number of LWPs */ | | 253 | int p_nlwps; /* p: Number of LWPs */ |
252 | int p_nzlwps; /* p: Number of zombie LWPs */ | | 254 | int p_nzlwps; /* p: Number of zombie LWPs */ |
253 | int p_nrlwps; /* p: Number running/sleeping LWPs */ | | 255 | int p_nrlwps; /* p: Number running/sleeping LWPs */ |
254 | int p_nlwpwait; /* p: Number of LWPs in lwp_wait1() */ | | 256 | int p_nlwpwait; /* p: Number of LWPs in lwp_wait1() */ |
255 | int p_ndlwps; /* p: Number of detached LWPs */ | | 257 | int p_ndlwps; /* p: Number of detached LWPs */ |
256 | int p_nlwpid; /* p: Next LWP ID */ | | 258 | int p_nlwpid; /* p: Next LWP ID */ |
257 | u_int p_nstopchild; /* l: Count of stopped/dead children */ | | 259 | u_int p_nstopchild; /* l: Count of stopped/dead children */ |
258 | u_int p_waited; /* l: parent has waited on child */ | | 260 | u_int p_waited; /* l: parent has waited on child */ |
259 | struct lwp *p_zomblwp; /* p: detached LWP to be reaped */ | | 261 | struct lwp *p_zomblwp; /* p: detached LWP to be reaped */ |
260 | | | 262 | |
261 | struct sadata *p_sa; /* p: Scheduler activation info */ | | 263 | struct sadata *p_sa; /* p: Scheduler activation info */ |
262 | | | 264 | |
263 | /* scheduling */ | | 265 | /* scheduling */ |
264 | void *p_sched_info; /* p: Scheduler-specific structure */ | | 266 | void *p_sched_info; /* p: Scheduler-specific structure */ |
265 | fixpt_t p_estcpu; /* p: Time avg. value of p_cpticks */ | | 267 | fixpt_t p_estcpu; /* p: Time avg. value of p_cpticks */ |
266 | fixpt_t p_estcpu_inherited; /* p: cpu inherited from children */ | | 268 | fixpt_t p_estcpu_inherited; /* p: cpu inherited from children */ |
267 | unsigned int p_forktime; | | 269 | unsigned int p_forktime; |
268 | fixpt_t p_pctcpu; /* p: %cpu from dead LWPs */ | | 270 | fixpt_t p_pctcpu; /* p: %cpu from dead LWPs */ |
269 | | | 271 | |
270 | struct proc *p_opptr; /* l: save parent during ptrace. */ | | 272 | struct proc *p_opptr; /* l: save parent during ptrace. */ |
271 | struct ptimers *p_timers; /* Timers: real, virtual, profiling */ | | 273 | struct ptimers *p_timers; /* Timers: real, virtual, profiling */ |
272 | struct bintime p_rtime; /* p: real time */ | | 274 | struct bintime p_rtime; /* p: real time */ |
273 | u_quad_t p_uticks; /* t: Statclock hits in user mode */ | | 275 | u_quad_t p_uticks; /* t: Statclock hits in user mode */ |
274 | u_quad_t p_sticks; /* t: Statclock hits in system mode */ | | 276 | u_quad_t p_sticks; /* t: Statclock hits in system mode */ |
275 | u_quad_t p_iticks; /* t: Statclock hits processing intr */ | | 277 | u_quad_t p_iticks; /* t: Statclock hits processing intr */ |
276 | | | 278 | |
277 | int p_traceflag; /* k: Kernel trace points */ | | 279 | int p_traceflag; /* k: Kernel trace points */ |
278 | int p_timerpend; /* p: Pending itimer to run */ | | 280 | int p_timerpend; /* p: Pending itimer to run */ |
279 | void *p_tracep; /* k: Trace private data */ | | 281 | void *p_tracep; /* k: Trace private data */ |
280 | struct vnode *p_textvp; /* :: Vnode of executable */ | | 282 | struct vnode *p_textvp; /* :: Vnode of executable */ |
281 | | | 283 | |
282 | struct emul *p_emul; /* :: emulation information */ | | 284 | struct emul *p_emul; /* :: emulation information */ |
283 | void *p_emuldata; /* :: per-proc emul data, or NULL */ | | 285 | void *p_emuldata; /* :: per-proc emul data, or NULL */ |
284 | const struct execsw *p_execsw; /* :: exec package information */ | | 286 | const struct execsw *p_execsw; /* :: exec package information */ |
285 | struct klist p_klist; /* p: knotes attached to proc */ | | 287 | struct klist p_klist; /* p: knotes attached to proc */ |
286 | | | 288 | |
287 | LIST_HEAD(, lwp) p_sigwaiters; /* p: LWPs waiting for signals */ | | 289 | LIST_HEAD(, lwp) p_sigwaiters; /* p: LWPs waiting for signals */ |
288 | sigpend_t p_sigpend; /* p: pending signals */ | | 290 | sigpend_t p_sigpend; /* p: pending signals */ |
289 | struct lcproc *p_lwpctl; /* p, a: _lwp_ctl() information */ | | 291 | struct lcproc *p_lwpctl; /* p, a: _lwp_ctl() information */ |
290 | pid_t p_ppid; /* :: cached parent pid */ | | 292 | pid_t p_ppid; /* :: cached parent pid */ |
291 | | | 293 | |
292 | /* | | 294 | /* |
293 | * End area that is zeroed on creation | | 295 | * End area that is zeroed on creation |
294 | */ | | 296 | */ |
295 | #define p_endzero p_startcopy | | 297 | #define p_endzero p_startcopy |
296 | | | 298 | |
297 | /* | | 299 | /* |
298 | * The following fields are all copied upon creation in fork. | | 300 | * The following fields are all copied upon creation in fork. |
299 | */ | | 301 | */ |
300 | #define p_startcopy p_sigctx | | 302 | #define p_startcopy p_sigctx |
301 | | | 303 | |
302 | struct sigctx p_sigctx; /* p: Shared signal state */ | | 304 | struct sigctx p_sigctx; /* p: Shared signal state */ |
303 | | | 305 | |
304 | u_char p_nice; /* p: Process "nice" value */ | | 306 | u_char p_nice; /* p: Process "nice" value */ |
305 | char p_comm[MAXCOMLEN+1]; | | 307 | char p_comm[MAXCOMLEN+1]; |
306 | /* p: basename of last exec file */ | | 308 | /* p: basename of last exec file */ |
307 | struct pgrp *p_pgrp; /* l: Pointer to process group */ | | 309 | struct pgrp *p_pgrp; /* l: Pointer to process group */ |
308 | | | 310 | |
309 | vaddr_t p_psstrp; /* :: address of process's ps_strings */ | | 311 | vaddr_t p_psstrp; /* :: address of process's ps_strings */ |
310 | u_int p_pax; /* :: PAX flags */ | | 312 | u_int p_pax; /* :: PAX flags */ |
311 | | | 313 | |
312 | /* | | 314 | /* |
313 | * End area that is copied on creation | | 315 | * End area that is copied on creation |
314 | */ | | 316 | */ |
315 | #define p_endcopy p_xstat | | 317 | #define p_endcopy p_xstat |
316 | | | 318 | |
317 | u_short p_xstat; /* p: Exit status for wait; also stop signal */ | | 319 | u_short p_xstat; /* p: Exit status for wait; also stop signal */ |
318 | u_short p_acflag; /* p: Acc. flags; see struct lwp also */ | | 320 | u_short p_acflag; /* p: Acc. flags; see struct lwp also */ |
319 | struct mdproc p_md; /* p: Any machine-dependent fields */ | | 321 | struct mdproc p_md; /* p: Any machine-dependent fields */ |
320 | vaddr_t p_stackbase; /* :: ASLR randomized stack base */ | | 322 | vaddr_t p_stackbase; /* :: ASLR randomized stack base */ |
321 | struct kdtrace_proc *p_dtrace; /* :: DTrace-specific data. */ | | 323 | struct kdtrace_proc *p_dtrace; /* :: DTrace-specific data. */ |
322 | }; | | 324 | }; |
323 | | | 325 | |
324 | #define p_rlimit p_limit->pl_rlimit | | 326 | #define p_rlimit p_limit->pl_rlimit |
325 | #define p_session p_pgrp->pg_session | | 327 | #define p_session p_pgrp->pg_session |
326 | #define p_pgid p_pgrp->pg_id | | 328 | #define p_pgid p_pgrp->pg_id |
327 | | | 329 | |
328 | /* | | 330 | /* |
329 | * Status values. | | 331 | * Status values. |
330 | */ | | 332 | */ |
331 | #define SIDL 1 /* Process being created by fork */ | | 333 | #define SIDL 1 /* Process being created by fork */ |
332 | #define SACTIVE 2 /* Process is not stopped */ | | 334 | #define SACTIVE 2 /* Process is not stopped */ |
333 | #define SDYING 3 /* About to die */ | | 335 | #define SDYING 3 /* About to die */ |
334 | #define SSTOP 4 /* Process debugging or suspension */ | | 336 | #define SSTOP 4 /* Process debugging or suspension */ |
335 | #define SZOMB 5 /* Awaiting collection by parent */ | | 337 | #define SZOMB 5 /* Awaiting collection by parent */ |
336 | #define SDEAD 6 /* Almost a zombie */ | | 338 | #define SDEAD 6 /* Almost a zombie */ |
337 | | | 339 | |
338 | #define P_ZOMBIE(p) \ | | 340 | #define P_ZOMBIE(p) \ |
339 | ((p)->p_stat == SZOMB || (p)->p_stat == SDYING || (p)->p_stat == SDEAD) | | 341 | ((p)->p_stat == SZOMB || (p)->p_stat == SDYING || (p)->p_stat == SDEAD) |
340 | | | 342 | |
341 | /* | | 343 | /* |
342 | * These flags are kept in p_flag and are protected by p_lock. Access from | | 344 | * These flags are kept in p_flag and are protected by p_lock. Access from |
343 | * process context only. | | 345 | * process context only. |
344 | */ | | 346 | */ |
345 | #define PK_ADVLOCK 0x00000001 /* Process may hold a POSIX advisory lock */ | | 347 | #define PK_ADVLOCK 0x00000001 /* Process may hold a POSIX advisory lock */ |
346 | #define PK_SYSTEM 0x00000002 /* System process (kthread) */ | | 348 | #define PK_SYSTEM 0x00000002 /* System process (kthread) */ |
347 | #define PK_SYSVSEM 0x00000004 /* Used SysV semaphores */ | | 349 | #define PK_SYSVSEM 0x00000004 /* Used SysV semaphores */ |
348 | #define PK_SUGID 0x00000100 /* Had set id privileges since last exec */ | | 350 | #define PK_SUGID 0x00000100 /* Had set id privileges since last exec */ |
349 | #define PK_EXEC 0x00004000 /* Process called exec */ | | 351 | #define PK_EXEC 0x00004000 /* Process called exec */ |
350 | #define PK_NOCLDWAIT 0x00020000 /* No zombies if child dies */ | | 352 | #define PK_NOCLDWAIT 0x00020000 /* No zombies if child dies */ |
351 | #define PK_32 0x00040000 /* 32-bit process (used on 64-bit kernels) */ | | 353 | #define PK_32 0x00040000 /* 32-bit process (used on 64-bit kernels) */ |
352 | #define PK_CLDSIGIGN 0x00080000 /* Process is ignoring SIGCHLD */ | | 354 | #define PK_CLDSIGIGN 0x00080000 /* Process is ignoring SIGCHLD */ |
353 | #define PK_MARKER 0x80000000 /* Is a dummy marker process */ | | 355 | #define PK_MARKER 0x80000000 /* Is a dummy marker process */ |
354 | | | 356 | |
355 | /* | | 357 | /* |
356 | * These flags are kept in p_sflag and are protected by p_lock. Access from | | 358 | * These flags are kept in p_sflag and are protected by p_lock. Access from |
357 | * process context only. | | 359 | * process context only. |
358 | */ | | 360 | */ |
359 | #define PS_NOCLDSTOP 0x00000008 /* No SIGCHLD when children stop */ | | 361 | #define PS_NOCLDSTOP 0x00000008 /* No SIGCHLD when children stop */ |
360 | #define PS_SA 0x00000400 /* Process using scheduler activations */ | | 362 | #define PS_SA 0x00000400 /* Process using scheduler activations */ |
361 | #define PS_WCORE 0x00001000 /* Process needs to dump core */ | | 363 | #define PS_WCORE 0x00001000 /* Process needs to dump core */ |
362 | #define PS_WEXIT 0x00002000 /* Working on exiting */ | | 364 | #define PS_WEXIT 0x00002000 /* Working on exiting */ |
363 | #define PS_STOPFORK 0x00800000 /* Child will be stopped on fork(2) */ | | 365 | #define PS_STOPFORK 0x00800000 /* Child will be stopped on fork(2) */ |
364 | #define PS_STOPEXEC 0x01000000 /* Will be stopped on exec(2) */ | | 366 | #define PS_STOPEXEC 0x01000000 /* Will be stopped on exec(2) */ |
365 | #define PS_STOPEXIT 0x02000000 /* Will be stopped at process exit */ | | 367 | #define PS_STOPEXIT 0x02000000 /* Will be stopped at process exit */ |
366 | #define PS_NOTIFYSTOP 0x10000000 /* Notify parent of successful STOP */ | | 368 | #define PS_NOTIFYSTOP 0x10000000 /* Notify parent of successful STOP */ |
367 | #define PS_NOSA 0x40000000 /* Do not enable SA */ | | 369 | #define PS_NOSA 0x40000000 /* Do not enable SA */ |
368 | #define PS_STOPPING 0x80000000 /* Transitioning SACTIVE -> SSTOP */ | | 370 | #define PS_STOPPING 0x80000000 /* Transitioning SACTIVE -> SSTOP */ |
369 | #define PS_RUMP_LWPEXIT PS_SA /* LWPs in rump kernel should exit for g/c */ | | 371 | #define PS_RUMP_LWPEXIT PS_SA /* LWPs in rump kernel should exit for g/c */ |
370 | | | 372 | |
371 | /* | | 373 | /* |
372 | * These flags are kept in p_sflag and are protected by the proc_lock | | 374 | * These flags are kept in p_sflag and are protected by the proc_lock |
373 | * and p_lock. Access from process context only. | | 375 | * and p_lock. Access from process context only. |
374 | */ | | 376 | */ |
375 | #define PSL_TRACED 0x00000800 /* Debugged process being traced */ | | 377 | #define PSL_TRACED 0x00000800 /* Debugged process being traced */ |
376 | #define PSL_FSTRACE 0x00010000 /* Debugger process being traced by procfs */ | | 378 | #define PSL_FSTRACE 0x00010000 /* Debugger process being traced by procfs */ |
377 | #define PSL_CHTRACED 0x00400000 /* Child has been traced & reparented */ | | 379 | #define PSL_CHTRACED 0x00400000 /* Child has been traced & reparented */ |
378 | #define PSL_SYSCALL 0x04000000 /* process has PT_SYSCALL enabled */ | | 380 | #define PSL_SYSCALL 0x04000000 /* process has PT_SYSCALL enabled */ |
379 | | | 381 | |
380 | /* | | 382 | /* |
381 | * Kept in p_stflag and protected by p_stmutex. | | 383 | * Kept in p_stflag and protected by p_stmutex. |
382 | */ | | 384 | */ |
383 | #define PST_PROFIL 0x00000020 /* Has started profiling */ | | 385 | #define PST_PROFIL 0x00000020 /* Has started profiling */ |
384 | | | 386 | |
385 | /* | | 387 | /* |
386 | * The final set are protected by the proc_lock. Access | | 388 | * The final set are protected by the proc_lock. Access |
387 | * from process context only. | | 389 | * from process context only. |
388 | */ | | 390 | */ |
389 | #define PL_CONTROLT 0x00000002 /* Has a controlling terminal */ | | 391 | #define PL_CONTROLT 0x00000002 /* Has a controlling terminal */ |
390 | #define PL_PPWAIT 0x00000010 /* Parent is waiting for child exec/exit */ | | 392 | #define PL_PPWAIT 0x00000010 /* Parent is waiting for child exec/exit */ |
391 | #define PL_SIGCOMPAT 0x00000200 /* Has used compat signal trampoline */ | | 393 | #define PL_SIGCOMPAT 0x00000200 /* Has used compat signal trampoline */ |
392 | #define PL_ORPHANPG 0x20000000 /* Member of an orphaned pgrp */ | | 394 | #define PL_ORPHANPG 0x20000000 /* Member of an orphaned pgrp */ |
393 | | | 395 | |
394 | /* | | 396 | /* |
395 | * Macro to compute the exit signal to be delivered. | | 397 | * Macro to compute the exit signal to be delivered. |
396 | */ | | 398 | */ |
397 | #define P_EXITSIG(p) \ | | 399 | #define P_EXITSIG(p) \ |
398 | (((p)->p_slflag & (PSL_TRACED|PSL_FSTRACE)) ? SIGCHLD : p->p_exitsig) | | 400 | (((p)->p_slflag & (PSL_TRACED|PSL_FSTRACE)) ? SIGCHLD : p->p_exitsig) |
399 | | | 401 | |
400 | LIST_HEAD(proclist, proc); /* A list of processes */ | | 402 | LIST_HEAD(proclist, proc); /* A list of processes */ |
401 | | | 403 | |
402 | /* | | 404 | /* |
403 | * This structure associates a proclist with its lock. | | 405 | * This structure associates a proclist with its lock. |
404 | */ | | 406 | */ |
405 | struct proclist_desc { | | 407 | struct proclist_desc { |
406 | struct proclist *pd_list; /* The list */ | | 408 | struct proclist *pd_list; /* The list */ |
407 | /* | | 409 | /* |
408 | * XXX Add a pointer to the proclist's lock eventually. | | 410 | * XXX Add a pointer to the proclist's lock eventually. |
409 | */ | | 411 | */ |
410 | }; | | 412 | }; |
411 | | | 413 | |
412 | #ifdef _KERNEL | | 414 | #ifdef _KERNEL |
413 | | | 415 | |
414 | /* | | 416 | /* |
415 | * We use process IDs <= PID_MAX until there are > 16k processes. | | 417 | * We use process IDs <= PID_MAX until there are > 16k processes. |
416 | * NO_PGID is used to represent "no process group" for a tty. | | 418 | * NO_PGID is used to represent "no process group" for a tty. |
417 | */ | | 419 | */ |
418 | #define PID_MAX 30000 | | 420 | #define PID_MAX 30000 |
419 | #define NO_PGID ((pid_t)-1) | | 421 | #define NO_PGID ((pid_t)-1) |
420 | | | 422 | |
421 | #define SESS_LEADER(p) ((p)->p_session->s_leader == (p)) | | 423 | #define SESS_LEADER(p) ((p)->p_session->s_leader == (p)) |
422 | | | 424 | |
423 | /* | | 425 | /* |
424 | * Flags passed to fork1(). | | 426 | * Flags passed to fork1(). |
425 | */ | | 427 | */ |
426 | #define FORK_PPWAIT 0x0001 /* Block parent until child exit */ | | 428 | #define FORK_PPWAIT 0x0001 /* Block parent until child exit */ |
427 | #define FORK_SHAREVM 0x0002 /* Share vmspace with parent */ | | 429 | #define FORK_SHAREVM 0x0002 /* Share vmspace with parent */ |
428 | #define FORK_SHARECWD 0x0004 /* Share cdir/rdir/cmask */ | | 430 | #define FORK_SHARECWD 0x0004 /* Share cdir/rdir/cmask */ |
429 | #define FORK_SHAREFILES 0x0008 /* Share file descriptors */ | | 431 | #define FORK_SHAREFILES 0x0008 /* Share file descriptors */ |
430 | #define FORK_SHARESIGS 0x0010 /* Share signal actions */ | | 432 | #define FORK_SHARESIGS 0x0010 /* Share signal actions */ |
431 | #define FORK_NOWAIT 0x0020 /* Make init the parent of the child */ | | 433 | #define FORK_NOWAIT 0x0020 /* Make init the parent of the child */ |
432 | #define FORK_CLEANFILES 0x0040 /* Start with a clean descriptor set */ | | 434 | #define FORK_CLEANFILES 0x0040 /* Start with a clean descriptor set */ |
433 | #define FORK_SYSTEM 0x0080 /* Fork a kernel thread */ | | 435 | #define FORK_SYSTEM 0x0080 /* Fork a kernel thread */ |
434 | | | 436 | |
435 | extern struct proc proc0; /* Process slot for swapper */ | | 437 | extern struct proc proc0; /* Process slot for swapper */ |
436 | extern u_int nprocs; /* Current number of procs */ | | 438 | extern u_int nprocs; /* Current number of procs */ |
437 | extern int maxproc; /* Max number of procs */ | | 439 | extern int maxproc; /* Max number of procs */ |
438 | #define vmspace_kernel() (proc0.p_vmspace) | | 440 | #define vmspace_kernel() (proc0.p_vmspace) |
439 | | | 441 | |
440 | extern kmutex_t *proc_lock; | | 442 | extern kmutex_t *proc_lock; |
441 | extern struct proclist allproc; /* List of all processes */ | | 443 | extern struct proclist allproc; /* List of all processes */ |
442 | extern struct proclist zombproc; /* List of zombie processes */ | | 444 | extern struct proclist zombproc; /* List of zombie processes */ |
443 | | | 445 | |
444 | extern struct proc *initproc; /* Process slots for init, pager */ | | 446 | extern struct proc *initproc; /* Process slots for init, pager */ |
445 | | | 447 | |
446 | extern const struct proclist_desc proclists[]; | | 448 | extern const struct proclist_desc proclists[]; |
447 | | | 449 | |
448 | extern struct pool ptimer_pool; /* Memory pool for ptimers */ | | 450 | extern struct pool ptimer_pool; /* Memory pool for ptimers */ |
449 | | | 451 | |
450 | struct simplelock; | | 452 | struct simplelock; |
451 | | | 453 | |
452 | proc_t * proc_find_raw(pid_t); | | 454 | proc_t * proc_find_raw(pid_t); |
453 | proc_t * proc_find(pid_t); /* Find process by ID */ | | 455 | proc_t * proc_find(pid_t); /* Find process by ID */ |
454 | struct pgrp * pgrp_find(pid_t); /* Find process group by ID */ | | 456 | struct pgrp * pgrp_find(pid_t); /* Find process group by ID */ |
455 | | | 457 | |
456 | void procinit(void); | | 458 | void procinit(void); |
457 | void procinit_sysctl(void); | | 459 | void procinit_sysctl(void); |
458 | int proc_enterpgrp(struct proc *, pid_t, pid_t, bool); | | 460 | int proc_enterpgrp(struct proc *, pid_t, pid_t, bool); |
459 | void proc_leavepgrp(struct proc *); | | 461 | void proc_leavepgrp(struct proc *); |
460 | void proc_sesshold(struct session *); | | 462 | void proc_sesshold(struct session *); |
461 | void proc_sessrele(struct session *); | | 463 | void proc_sessrele(struct session *); |
462 | void fixjobc(struct proc *, struct pgrp *, int); | | 464 | void fixjobc(struct proc *, struct pgrp *, int); |
463 | | | 465 | |
464 | int ltsleep(wchan_t, pri_t, const char *, int, volatile struct simplelock *); | | 466 | int ltsleep(wchan_t, pri_t, const char *, int, volatile struct simplelock *); |
465 | int mtsleep(wchan_t, pri_t, const char *, int, kmutex_t *); | | 467 | int mtsleep(wchan_t, pri_t, const char *, int, kmutex_t *); |
466 | void wakeup(wchan_t); | | 468 | void wakeup(wchan_t); |
467 | void wakeup_one(wchan_t); | | 469 | void wakeup_one(wchan_t); |
468 | int kpause(const char *, bool, int, kmutex_t *); | | 470 | int kpause(const char *, bool, int, kmutex_t *); |
469 | void exit1(struct lwp *, int) __dead; | | 471 | void exit1(struct lwp *, int) __dead; |
470 | int do_sys_wait(int *, int *, int, struct rusage *); | | 472 | int do_sys_wait(int *, int *, int, struct rusage *); |
471 | struct proc *proc_alloc(void); | | 473 | struct proc *proc_alloc(void); |
472 | void proc0_init(void); | | 474 | void proc0_init(void); |
473 | pid_t proc_alloc_pid(struct proc *); | | 475 | pid_t proc_alloc_pid(struct proc *); |
474 | void proc_free_pid(pid_t); | | 476 | void proc_free_pid(pid_t); |
475 | void proc_free_mem(struct proc *); | | 477 | void proc_free_mem(struct proc *); |
476 | void exit_lwps(struct lwp *l); | | 478 | void exit_lwps(struct lwp *l); |
477 | int fork1(struct lwp *, int, int, void *, size_t, | | 479 | int fork1(struct lwp *, int, int, void *, size_t, |
478 | void (*)(void *), void *, register_t *, struct proc **); | | 480 | void (*)(void *), void *, register_t *, struct proc **); |
479 | int pgid_in_session(struct proc *, pid_t); | | 481 | int pgid_in_session(struct proc *, pid_t); |
480 | void cpu_lwp_fork(struct lwp *, struct lwp *, void *, size_t, | | 482 | void cpu_lwp_fork(struct lwp *, struct lwp *, void *, size_t, |
481 | void (*)(void *), void *); | | 483 | void (*)(void *), void *); |
482 | void cpu_lwp_free(struct lwp *, int); | | 484 | void cpu_lwp_free(struct lwp *, int); |
483 | void cpu_lwp_free2(struct lwp *); | | 485 | void cpu_lwp_free2(struct lwp *); |
484 | | | 486 | |
485 | #ifdef __HAVE_SYSCALL_INTERN | | 487 | #ifdef __HAVE_SYSCALL_INTERN |
486 | void syscall_intern(struct proc *); | | 488 | void syscall_intern(struct proc *); |
487 | #endif | | 489 | #endif |
488 | | | 490 | |
489 | void child_return(void *); | | 491 | void child_return(void *); |
490 | | | 492 | |
491 | int proc_isunder(struct proc *, struct lwp *); | | 493 | int proc_isunder(struct proc *, struct lwp *); |
492 | void proc_stop(struct proc *, int, int); | | 494 | void proc_stop(struct proc *, int, int); |
493 | int proc_uidmatch(kauth_cred_t, kauth_cred_t); | | 495 | int proc_uidmatch(kauth_cred_t, kauth_cred_t); |
494 | | | 496 | |
495 | int proc_vmspace_getref(struct proc *, struct vmspace **); | | 497 | int proc_vmspace_getref(struct proc *, struct vmspace **); |
496 | void proc_crmod_leave(kauth_cred_t, kauth_cred_t, bool); | | 498 | void proc_crmod_leave(kauth_cred_t, kauth_cred_t, bool); |
497 | void proc_crmod_enter(void); | | 499 | void proc_crmod_enter(void); |
498 | | | 500 | |
499 | int proc_specific_key_create(specificdata_key_t *, specificdata_dtor_t); | | 501 | int proc_specific_key_create(specificdata_key_t *, specificdata_dtor_t); |
500 | void proc_specific_key_delete(specificdata_key_t); | | 502 | void proc_specific_key_delete(specificdata_key_t); |
501 | void proc_initspecific(struct proc *); | | 503 | void proc_initspecific(struct proc *); |
502 | void proc_finispecific(struct proc *); | | 504 | void proc_finispecific(struct proc *); |
503 | void * proc_getspecific(struct proc *, specificdata_key_t); | | 505 | void * proc_getspecific(struct proc *, specificdata_key_t); |
504 | void proc_setspecific(struct proc *, specificdata_key_t, void *); | | 506 | void proc_setspecific(struct proc *, specificdata_key_t, void *); |
505 | | | 507 | |
506 | int proclist_foreach_call(struct proclist *, | | 508 | int proclist_foreach_call(struct proclist *, |
507 | int (*)(struct proc *, void *arg), void *); | | 509 | int (*)(struct proc *, void *arg), void *); |
508 | | | 510 | |
509 | static inline struct proc * | | 511 | static inline struct proc * |
510 | _proclist_skipmarker(struct proc *p0) | | 512 | _proclist_skipmarker(struct proc *p0) |
511 | { | | 513 | { |
512 | struct proc *p = p0; | | 514 | struct proc *p = p0; |
513 | | | 515 | |
514 | while (p != NULL && p->p_flag & PK_MARKER) | | 516 | while (p != NULL && p->p_flag & PK_MARKER) |
515 | p = LIST_NEXT(p, p_list); | | 517 | p = LIST_NEXT(p, p_list); |
516 | | | 518 | |
517 | return p; | | 519 | return p; |
518 | } | | 520 | } |
519 | | | 521 | |
520 | /* | | 522 | /* |
521 | * PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones. | | 523 | * PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones. |
522 | */ | | 524 | */ |
523 | #define PROCLIST_FOREACH(var, head) \ | | 525 | #define PROCLIST_FOREACH(var, head) \ |
524 | for ((var) = LIST_FIRST(head); \ | | 526 | for ((var) = LIST_FIRST(head); \ |
525 | ((var) = _proclist_skipmarker(var)) != NULL; \ | | 527 | ((var) = _proclist_skipmarker(var)) != NULL; \ |
526 | (var) = LIST_NEXT(var, p_list)) | | 528 | (var) = LIST_NEXT(var, p_list)) |
527 | | | 529 | |
528 | /* Compatibility with old, non-interlocked tsleep call */ | | 530 | /* Compatibility with old, non-interlocked tsleep call */ |
529 | #define tsleep(chan, pri, wmesg, timo) \ | | 531 | #define tsleep(chan, pri, wmesg, timo) \ |
530 | ltsleep(chan, pri, wmesg, timo, NULL) | | 532 | ltsleep(chan, pri, wmesg, timo, NULL) |
531 | | | 533 | |
532 | #ifdef KSTACK_CHECK_MAGIC | | 534 | #ifdef KSTACK_CHECK_MAGIC |
533 | void kstack_setup_magic(const struct lwp *); | | 535 | void kstack_setup_magic(const struct lwp *); |
534 | void kstack_check_magic(const struct lwp *); | | 536 | void kstack_check_magic(const struct lwp *); |
535 | #else | | 537 | #else |
536 | #define kstack_setup_magic(x) | | 538 | #define kstack_setup_magic(x) |
537 | #define kstack_check_magic(x) | | 539 | #define kstack_check_magic(x) |
538 | #endif | | 540 | #endif |
539 | | | 541 | |
540 | extern struct emul emul_netbsd; | | 542 | extern struct emul emul_netbsd; |
541 | | | 543 | |
542 | #endif /* _KERNEL */ | | 544 | #endif /* _KERNEL */ |
543 | | | 545 | |
544 | #if defined(_KMEMUSER) || defined(_KERNEL) | | 546 | #if defined(_KMEMUSER) || defined(_KERNEL) |
545 | | | 547 | |
546 | /* | | 548 | /* |
547 | * Kernel stack parameters. | | 549 | * Kernel stack parameters. |
548 | * | | 550 | * |
549 | * KSTACK_LOWEST_ADDR: return the lowest address of the LWP's kernel stack, | | 551 | * KSTACK_LOWEST_ADDR: return the lowest address of the LWP's kernel stack, |
550 | * excluding red-zone. | | 552 | * excluding red-zone. |
551 | * | | 553 | * |
552 | * KSTACK_SIZE: the size kernel stack for a LWP, excluding red-zone. | | 554 | * KSTACK_SIZE: the size kernel stack for a LWP, excluding red-zone. |
553 | * | | 555 | * |
554 | * if <machine/proc.h> provides the MD definition, it will be used. | | 556 | * if <machine/proc.h> provides the MD definition, it will be used. |
555 | */ | | 557 | */ |
556 | #ifndef KSTACK_LOWEST_ADDR | | 558 | #ifndef KSTACK_LOWEST_ADDR |
557 | #define KSTACK_LOWEST_ADDR(l) ((void *)ALIGN((struct pcb *)((l)->l_addr) + 1)) | | 559 | #define KSTACK_LOWEST_ADDR(l) ((void *)ALIGN((struct pcb *)((l)->l_addr) + 1)) |
558 | #endif | | 560 | #endif |
559 | #ifndef KSTACK_SIZE | | 561 | #ifndef KSTACK_SIZE |
560 | #define KSTACK_SIZE (USPACE - ALIGN(sizeof(struct pcb))) | | 562 | #define KSTACK_SIZE (USPACE - ALIGN(sizeof(struct pcb))) |
561 | #endif | | 563 | #endif |
562 | | | 564 | |
563 | #endif /* _KMEMUSER || _KERNEL */ | | 565 | #endif /* _KMEMUSER || _KERNEL */ |
564 | | | 566 | |
565 | #endif /* !_SYS_PROC_H_ */ | | 567 | #endif /* !_SYS_PROC_H_ */ |