FreeBSD/Linux Kernel Cross Reference
sys/sys/proc.h
1 /*-
2 * Copyright (c) 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)proc.h 8.15 (Berkeley) 5/19/95
39 * $FreeBSD: releng/5.2/sys/sys/proc.h 122769 2003-11-15 23:57:19Z imp $
40 */
41
42 #ifndef _SYS_PROC_H_
43 #define _SYS_PROC_H_
44
45 #include <sys/callout.h> /* For struct callout. */
46 #include <sys/event.h> /* For struct klist. */
47 #ifndef _KERNEL
48 #include <sys/filedesc.h>
49 #endif
50 #include <sys/_lock.h>
51 #include <sys/_mutex.h>
52 #include <sys/queue.h>
53 #include <sys/priority.h>
54 #include <sys/rtprio.h> /* XXX. */
55 #include <sys/runq.h>
56 #include <sys/sigio.h>
57 #include <sys/signal.h>
58 #ifndef _KERNEL
59 #include <sys/time.h> /* For structs itimerval, timeval. */
60 #else
61 #include <sys/pcpu.h>
62 #endif
63 #include <sys/ucontext.h>
64 #include <sys/ucred.h>
65 #include <machine/proc.h> /* Machine-dependent proc substruct. */
66
67 /*
68 * One structure allocated per session.
69 *
70 * List of locks
71 * (m) locked by s_mtx mtx
72 * (e) locked by proctree_lock sx
73 * (c) const until freeing
74 */
75 struct session {
76 int s_count; /* (m) Ref cnt; pgrps in session. */
77 struct proc *s_leader; /* (m + e) Session leader. */
78 struct vnode *s_ttyvp; /* (m) Vnode of controlling tty. */
79 struct tty *s_ttyp; /* (m) Controlling tty. */
80 pid_t s_sid; /* (c) Session ID. */
81 /* (m) Setlogin() name: */
82 char s_login[roundup(MAXLOGNAME, sizeof(long))];
83 struct mtx s_mtx; /* Mutex to protect members. */
84 };
85
86 /*
87 * One structure allocated per process group.
88 *
89 * List of locks
90 * (m) locked by pg_mtx mtx
91 * (e) locked by proctree_lock sx
92 * (c) const until freeing
93 */
94 struct pgrp {
95 LIST_ENTRY(pgrp) pg_hash; /* (e) Hash chain. */
96 LIST_HEAD(, proc) pg_members; /* (m + e) Pointer to pgrp members. */
97 struct session *pg_session; /* (c) Pointer to session. */
98 struct sigiolst pg_sigiolst; /* (m) List of sigio sources. */
99 pid_t pg_id; /* (c) Pgrp id. */
100 int pg_jobc; /* (m) job cntl proc count */
101 struct mtx pg_mtx; /* Mutex to protect members */
102 };
103
104 /*
105 * pargs, used to hold a copy of the command line, if it had a sane length.
106 */
107 struct pargs {
108 u_int ar_ref; /* Reference count. */
109 u_int ar_length; /* Length. */
110 u_char ar_args[1]; /* Arguments. */
111 };
112
113 /*-
114 * Description of a process.
115 *
116 * This structure contains the information needed to manage a thread of
117 * control, known in UN*X as a process; it has references to substructures
118 * containing descriptions of things that the process uses, but may share
119 * with related processes. The process structure and the substructures
120 * are always addressable except for those marked "(CPU)" below,
121 * which might be addressable only on a processor on which the process
122 * is running.
123 *
124 * Below is a key of locks used to protect each member of struct proc. The
125 * lock is indicated by a reference to a specific character in parens in the
126 * associated comment.
127 * * - not yet protected
128 * a - only touched by curproc or parent during fork/wait
129 * b - created at fork, never changes
130 * (exception aiods switch vmspaces, but they are also
131 * marked 'P_SYSTEM' so hopefully it will be left alone)
132 * c - locked by proc mtx
133 * d - locked by allproc_lock lock
134 * e - locked by proctree_lock lock
135 * f - session mtx
136 * g - process group mtx
137 * h - callout_lock mtx
138 * i - by curproc or the master session mtx
139 * j - locked by sched_lock mtx
140 * k - only accessed by curthread
141 * l - the attaching proc or attaching proc parent
142 * m - Giant
143 * n - not locked, lazy
144 * o - ktrace lock
145 * p - select lock (sellock)
146 * q - td_contested lock
147 * r - p_peers lock
148 * x - created at fork, only changes during single threading in exec
149 * z - zombie threads/kse/ksegroup lock
150 *
151 * If the locking key specifies two identifiers (for example, p_pptr) then
152 * either lock is sufficient for read access, but both locks must be held
153 * for write access.
154 */
155 struct ithd;
156 struct ke_sched;
157 struct kg_sched;
158 struct nlminfo;
159 struct p_sched;
160 struct td_sched;
161 struct trapframe;
162 struct turnstile;
163
164 /*
165 * Here we define the four structures used for process information.
166 *
167 * The first is the thread. It might be though of as a "Kernel
168 * Schedulable Entity Context".
169 * This structure contains all the information as to where a thread of
170 * execution is now, or was when it was suspended, why it was suspended,
171 * and anything else that will be needed to restart it when it is
172 * rescheduled. Always associated with a KSE when running, but can be
173 * reassigned to an equivalent KSE when being restarted for
174 * load balancing. Each of these is associated with a kernel stack
175 * and a pcb.
176 *
177 * It is important to remember that a particular thread structure only
178 * exists as long as the system call or kernel entrance (e.g. by pagefault)
179 * which it is currently executing. It should therefore NEVER be referenced
180 * by pointers in long lived structures that live longer than a single
181 * request. If several threads complete their work at the same time,
182 * they will all rewind their stacks to the user boundary, report their
183 * completion state, and all but one will be freed. That last one will
184 * be kept to provide a kernel stack and pcb for the NEXT syscall or kernel
185 * entrance. (basically to save freeing and then re-allocating it) The KSE
186 * keeps a cached thread available to allow it to quickly
187 * get one when it needs a new one. There is also a system
188 * cache of free threads. Threads have priority and partake in priority
189 * inheritance schemes.
190 */
191 struct thread;
192
193 /*
194 * The second structure is the Kernel Schedulable Entity. (KSE)
195 * It represents the ability to take a slot in the scheduler queue.
196 * As long as this is scheduled, it could continue to run any threads that
197 * are assigned to the KSEGRP (see later) until either it runs out
198 * of runnable threads of high enough priority, or CPU.
199 * It runs on one CPU and is assigned a quantum of time. When a thread is
200 * blocked, The KSE continues to run and will search for another thread
201 * in a runnable state amongst those it has. It May decide to return to user
202 * mode with a new 'empty' thread if there are no runnable threads.
203 * Threads are temporarily associated with a KSE for scheduling reasons.
204 */
205 struct kse;
206
207 /*
208 * The KSEGRP is allocated resources across a number of CPUs.
209 * (Including a number of CPUxQUANTA. It parcels these QUANTA up among
210 * its KSEs, each of which should be running in a different CPU.
211 * BASE priority and total available quanta are properties of a KSEGRP.
212 * Multiple KSEGRPs in a single process compete against each other
213 * for total quanta in the same way that a forked child competes against
214 * it's parent process.
215 */
216 struct ksegrp;
217
218 /*
219 * A process is the owner of all system resources allocated to a task
220 * except CPU quanta.
221 * All KSEGs under one process see, and have the same access to, these
222 * resources (e.g. files, memory, sockets, permissions kqueues).
223 * A process may compete for CPU cycles on the same basis as a
224 * forked process cluster by spawning several KSEGRPs.
225 */
226 struct proc;
227
228 /***************
229 * In pictures:
230 With a single run queue used by all processors:
231
232 RUNQ: --->KSE---KSE--... SLEEPQ:[]---THREAD---THREAD---THREAD
233 | / []---THREAD
234 KSEG---THREAD--THREAD--THREAD []
235 []---THREAD---THREAD
236
237 (processors run THREADs from the KSEG until they are exhausted or
238 the KSEG exhausts its quantum)
239
240 With PER-CPU run queues:
241 KSEs on the separate run queues directly
242 They would be given priorities calculated from the KSEG.
243
244 *
245 *****************/
246
247 /*
248 * Kernel runnable context (thread).
249 * This is what is put to sleep and reactivated.
250 * The first KSE available in the correct group will run this thread.
251 * If several are available, use the one on the same CPU as last time.
252 * When waiting to be run, threads are hung off the KSEGRP in priority order.
253 * with N runnable and queued KSEs in the KSEGRP, the first N threads
254 * are linked to them. Other threads are not yet assigned.
255 */
256 struct thread {
257 struct proc *td_proc; /* (*) Associated process. */
258 struct ksegrp *td_ksegrp; /* (*) Associated KSEG. */
259 TAILQ_ENTRY(thread) td_plist; /* (*) All threads in this proc. */
260 TAILQ_ENTRY(thread) td_kglist; /* (*) All threads in this ksegrp. */
261
262 /* The two queues below should someday be merged. */
263 TAILQ_ENTRY(thread) td_slpq; /* (j) Sleep queue. */
264 TAILQ_ENTRY(thread) td_lockq; /* (j) Lock queue. */
265 TAILQ_ENTRY(thread) td_runq; /* (j/z) Run queue(s). XXXKSE */
266
267 TAILQ_HEAD(, selinfo) td_selq; /* (p) List of selinfos. */
268 struct turnstile *td_turnstile; /* (k) Associated turnstile. */
269
270 /* Cleared during fork1() or thread_sched_upcall(). */
271 #define td_startzero td_flags
272 int td_flags; /* (j) TDF_* flags. */
273 int td_inhibitors; /* (j) Why can not run. */
274 int td_pflags; /* (k) Private thread (TDP_*) flags. */
275 struct kse *td_last_kse; /* (j) Previous value of td_kse. */
276 struct kse *td_kse; /* (j) Current KSE if running. */
277 int td_dupfd; /* (k) Ret value from fdopen. XXX */
278 void *td_wchan; /* (j) Sleep address. */
279 const char *td_wmesg; /* (j) Reason for sleep. */
280 u_char td_lastcpu; /* (j) Last cpu we were on. */
281 u_char td_oncpu; /* (j) Which cpu we are on. */
282 short td_locks; /* (k) DEBUG: lockmgr count of locks. */
283 struct turnstile *td_blocked; /* (j) Lock process is blocked on. */
284 struct ithd *td_ithd; /* (b) For interrupt threads only. */
285 const char *td_lockname; /* (j) Name of lock blocked on. */
286 LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */
287 struct lock_list_entry *td_sleeplocks; /* (k) Held sleep locks. */
288 int td_intr_nesting_level; /* (k) Interrupt recursion. */
289 int td_pinned; /* (k) Temporary cpu pin count. */
290 struct kse_thr_mailbox *td_mailbox; /* (*) Userland mailbox address. */
291 struct ucred *td_ucred; /* (k) Reference to credentials. */
292 struct thread *td_standin; /* (*) Use this for an upcall. */
293 u_int td_prticks; /* (*) Profclock hits in sys for user */
294 struct kse_upcall *td_upcall; /* (*) Upcall structure. */
295 u_int64_t td_sticks; /* (j) Statclock hits in system mode. */
296 u_int td_uuticks; /* (*) Statclock in user, for UTS. */
297 u_int td_usticks; /* (*) Statclock in kernel, for UTS. */
298 int td_intrval; /* (*) Return value of TDF_INTERRUPT. */
299 sigset_t td_oldsigmask; /* (k) Saved mask from pre sigpause. */
300 sigset_t td_sigmask; /* (c) Current signal mask. */
301 sigset_t td_siglist; /* (c) Sigs arrived, not delivered. */
302 sigset_t *td_waitset; /* (c) Wait set for sigwait. */
303 TAILQ_ENTRY(thread) td_umtx; /* (c?) Link for when we're blocked. */
304 volatile u_int td_generation; /* (k) Enable detection of preemption */
305
306 #define td_endzero td_base_pri
307
308 /* Copied during fork1() or thread_sched_upcall(). */
309 #define td_startcopy td_endzero
310 u_char td_base_pri; /* (j) Thread base kernel priority. */
311 u_char td_priority; /* (j) Thread active priority. */
312 #define td_endcopy td_pcb
313
314 /*
315 * fields that must be manually set in fork1() or thread_sched_upcall()
316 * or already have been set in the allocator, contstructor, etc..
317 */
318 struct pcb *td_pcb; /* (k) Kernel VA of pcb and kstack. */
319 enum {
320 TDS_INACTIVE = 0x0,
321 TDS_INHIBITED,
322 TDS_CAN_RUN,
323 TDS_RUNQ,
324 TDS_RUNNING
325 } td_state;
326 register_t td_retval[2]; /* (k) Syscall aux returns. */
327 struct callout td_slpcallout; /* (h) Callout for sleep. */
328 struct trapframe *td_frame; /* (k) */
329 struct vm_object *td_kstack_obj;/* (a) Kstack object. */
330 vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */
331 int td_kstack_pages; /* (a) Size of the kstack. */
332 struct vm_object *td_altkstack_obj;/* (a) Alternate kstack object. */
333 vm_offset_t td_altkstack; /* (a) Kernel VA of alternate kstack. */
334 int td_altkstack_pages; /* (a) Size of the alternate kstack */
335 u_int td_critnest; /* (k) Critical section nest level. */
336 struct mdthread td_md; /* (k) Any machine-dependent fields. */
337 struct td_sched *td_sched; /* (*) Scheduler-specific data. */
338 };
339 /* flags kept in td_flags */
340 #define TDF_INPANIC 0x000002 /* Caused a panic, let it drive crashdump. */
341 #define TDF_CAN_UNBIND 0x000004 /* Only temporarily bound. */
342 #define TDF_SINTR 0x000008 /* Sleep is interruptible. */
343 #define TDF_TIMEOUT 0x000010 /* Timing out during sleep. */
344 #define TDF_IDLETD 0x000020 /* This is one of the per-CPU idle threads. */
345 #define TDF_SELECT 0x000040 /* Selecting; wakeup/waiting danger. */
346 #define TDF_CVWAITQ 0x000080 /* Thread is on a cv_waitq (not slpq). */
347 #define TDF_TSNOBLOCK 0x000100 /* Don't block on a turnstile due to race. */
348 #define TDF_ONSLEEPQ 0x000200 /* On the sleep queue. */
349 #define TDF_ASTPENDING 0x000800 /* Thread has some asynchronous events. */
350 #define TDF_TIMOFAIL 0x001000 /* Timeout from sleep after we were awake. */
351 #define TDF_INTERRUPT 0x002000 /* Thread is marked as interrupted. */
352 #define TDF_USTATCLOCK 0x004000 /* Stat clock hits in userland. */
353 #define TDF_OWEUPC 0x008000 /* Owe thread an addupc() call at next AST. */
354 #define TDF_NEEDRESCHED 0x010000 /* Thread needs to yield. */
355 #define TDF_NEEDSIGCHK 0x020000 /* Thread may need signal delivery. */
356 #define TDF_SA 0x040000 /* A scheduler activation based thread. */
357 #define TDF_UMTXWAKEUP 0x080000 /* Libthr thread must not sleep on a umtx. */
358 #define TDF_DEADLKTREAT 0x800000 /* Lock aquisition - deadlock treatment. */
359
360 /* "private" flags kept in td_pflags */
361 #define TDP_OLDMASK 0x0001 /* Need to restore mask after suspend. */
362 #define TDP_INKTR 0x0002 /* Thread is currently in KTR code. */
363 #define TDP_INKTRACE 0x0004 /* Thread is currently in KTRACE code. */
364 #define TDP_UPCALLING 0x0008 /* This thread is doing an upcall. */
365 #define TDP_COWINPROGRESS 0x0010 /* Snapshot copy-on-write in progress. */
366
367 #define TDI_SUSPENDED 0x0001 /* On suspension queue. */
368 #define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */
369 #define TDI_SWAPPED 0x0004 /* Stack not in mem.. bad juju if run. */
370 #define TDI_LOCK 0x0008 /* Stopped on a lock. */
371 #define TDI_IWAIT 0x0010 /* Awaiting interrupt. */
372
373 #define TD_CAN_UNBIND(td) \
374 (((td)->td_flags & TDF_CAN_UNBIND) == TDF_CAN_UNBIND && \
375 ((td)->td_upcall != NULL))
376
377 #define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING)
378 #define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL)
379 #define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED)
380 #define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED)
381 #define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK)
382 #define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT)
383 #define TD_IS_RUNNING(td) ((td)->td_state == TDS_RUNNING)
384 #define TD_ON_RUNQ(td) ((td)->td_state == TDS_RUNQ)
385 #define TD_CAN_RUN(td) ((td)->td_state == TDS_CAN_RUN)
386 #define TD_IS_INHIBITED(td) ((td)->td_state == TDS_INHIBITED)
387
388 #define TD_SET_INHIB(td, inhib) do { \
389 (td)->td_state = TDS_INHIBITED; \
390 (td)->td_inhibitors |= (inhib); \
391 } while (0)
392
393 #define TD_CLR_INHIB(td, inhib) do { \
394 if (((td)->td_inhibitors & (inhib)) && \
395 (((td)->td_inhibitors &= ~(inhib)) == 0)) \
396 (td)->td_state = TDS_CAN_RUN; \
397 } while (0)
398
399 #define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING)
400 #define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED)
401 #define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK)
402 #define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED)
403 #define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT)
404 #define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING)
405
406 #define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING)
407 #define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED)
408 #define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK)
409 #define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED)
410 #define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT)
411
412 #define TD_SET_RUNNING(td) do {(td)->td_state = TDS_RUNNING; } while (0)
413 #define TD_SET_RUNQ(td) do {(td)->td_state = TDS_RUNQ; } while (0)
414 #define TD_SET_CAN_RUN(td) do {(td)->td_state = TDS_CAN_RUN; } while (0)
415 #define TD_SET_ON_SLEEPQ(td) do {(td)->td_flags |= TDF_ONSLEEPQ; } while (0)
416 #define TD_CLR_ON_SLEEPQ(td) do { \
417 (td)->td_flags &= ~TDF_ONSLEEPQ; \
418 (td)->td_wchan = NULL; \
419 } while (0)
420
421 /*
422 * The schedulable entity that can be given a context to run.
423 * A process may have several of these. Probably one per processor
424 * but posibly a few more. In this universe they are grouped
425 * with a KSEG that contains the priority and niceness
426 * for the group.
427 */
428 struct kse {
429 struct proc *ke_proc; /* (*) Associated process. */
430 struct ksegrp *ke_ksegrp; /* (*) Associated KSEG. */
431 TAILQ_ENTRY(kse) ke_kglist; /* (*) Queue of KSEs in ke_ksegrp. */
432 TAILQ_ENTRY(kse) ke_kgrlist; /* (*) Queue of KSEs in this state. */
433 TAILQ_ENTRY(kse) ke_procq; /* (j/z) Run queue. */
434
435 #define ke_startzero ke_flags
436 int ke_flags; /* (j) KEF_* flags. */
437 struct thread *ke_thread; /* (*) Active associated thread. */
438 fixpt_t ke_pctcpu; /* (j) %cpu during p_swtime. */
439 u_char ke_oncpu; /* (j) Which cpu we are on. */
440 char ke_rqindex; /* (j) Run queue index. */
441 enum {
442 KES_UNUSED = 0x0,
443 KES_IDLE,
444 KES_ONRUNQ,
445 KES_UNQUEUED, /* in transit */
446 KES_THREAD /* slaved to thread state */
447 } ke_state; /* (j) KSE status. */
448 #define ke_endzero ke_dummy
449 u_char ke_dummy;
450 struct ke_sched *ke_sched; /* (*) Scheduler-specific data. */
451 };
452
453 /* flags kept in ke_flags */
454 #define KEF_SCHED0 0x00001 /* For scheduler-specific use. */
455 #define KEF_SCHED1 0x00002 /* For scheduler-specific use. */
456 #define KEF_SCHED2 0X00004 /* For scheduler-specific use. */
457 #define KEF_SCHED3 0x00008 /* For scheduler-specific use. */
458 #define KEF_DIDRUN 0x02000 /* KSE actually ran. */
459 #define KEF_EXIT 0x04000 /* KSE is being killed. */
460
461 /*
462 * The upcall management structure.
463 * The upcall is used when returning to userland. If a thread does not have
464 * an upcall on return to userland the thread exports its context and exits.
465 */
466 struct kse_upcall {
467 TAILQ_ENTRY(kse_upcall) ku_link; /* List of upcalls in KSEG. */
468 struct ksegrp *ku_ksegrp; /* Associated KSEG. */
469 struct thread *ku_owner; /* owning thread */
470 int ku_flags; /* KUF_* flags. */
471 struct kse_mailbox *ku_mailbox; /* userland mailbox address. */
472 stack_t ku_stack; /* userland upcall stack. */
473 void *ku_func; /* userland upcall function. */
474 unsigned int ku_mflags; /* cached upcall mailbox flags */
475 };
476
477 #define KUF_DOUPCALL 0x00001 /* Do upcall now, don't wait. */
478 #define KUF_EXITING 0x00002 /* Upcall structure is exiting. */
479
480 /*
481 * Kernel-scheduled entity group (KSEG). The scheduler considers each KSEG to
482 * be an indivisible unit from a time-sharing perspective, though each KSEG may
483 * contain multiple KSEs.
484 */
485 struct ksegrp {
486 struct proc *kg_proc; /* (*) Process that contains this KSEG. */
487 TAILQ_ENTRY(ksegrp) kg_ksegrp; /* (*) Queue of KSEGs in kg_proc. */
488 TAILQ_HEAD(, kse) kg_kseq; /* (ke_kglist) All KSEs. */
489 TAILQ_HEAD(, kse) kg_iq; /* (ke_kgrlist) All idle KSEs. */
490 TAILQ_HEAD(, thread) kg_threads;/* (td_kglist) All threads. */
491 TAILQ_HEAD(, thread) kg_runq; /* (td_runq) waiting RUNNABLE threads */
492 TAILQ_HEAD(, thread) kg_slpq; /* (td_runq) NONRUNNABLE threads. */
493 TAILQ_HEAD(, kse_upcall) kg_upcalls; /* All upcalls in the group. */
494 #define kg_startzero kg_estcpu
495 u_int kg_estcpu; /* (j) Sum of the same field in KSEs. */
496 u_int kg_slptime; /* (j) How long completely blocked. */
497 struct thread *kg_last_assigned; /* (j) Last thread assigned to a KSE. */
498 int kg_runnable; /* (j) Num runnable threads on queue. */
499 int kg_runq_kses; /* (j) Num KSEs on runq. */
500 int kg_idle_kses; /* (j) Num KSEs on iq. */
501 int kg_numupcalls; /* (j) Num upcalls. */
502 int kg_upsleeps; /* (c) Num threads in kse_release(). */
503 struct kse_thr_mailbox *kg_completed; /* (c) Completed thread mboxes. */
504 int kg_nextupcall; /* (*) Next upcall time. */
505 int kg_upquantum; /* (*) Quantum to schedule an upcall. */
506 #define kg_endzero kg_pri_class
507
508 #define kg_startcopy kg_endzero
509 u_char kg_pri_class; /* (j) Scheduling class. */
510 u_char kg_user_pri; /* (j) User pri from estcpu and nice. */
511 char kg_nice; /* (c + j) Process "nice" value. */
512 #define kg_endcopy kg_numthreads
513 int kg_numthreads; /* (j) Num threads in total. */
514 int kg_kses; /* (j) Num KSEs in group. */
515 struct kg_sched *kg_sched; /* (*) Scheduler-specific data. */
516 };
517
518 /*
519 * The old fashionned process. May have multiple threads, KSEGRPs
520 * and KSEs. Starts off with a single embedded KSEGRP, KSE and THREAD.
521 */
522 struct proc {
523 LIST_ENTRY(proc) p_list; /* (d) List of all processes. */
524 TAILQ_HEAD(, ksegrp) p_ksegrps; /* (kg_ksegrp) All KSEGs. */
525 TAILQ_HEAD(, thread) p_threads; /* (td_plist) Threads. (shortcut) */
526 TAILQ_HEAD(, thread) p_suspended; /* (td_runq) Suspended threads. */
527 struct ucred *p_ucred; /* (c) Process owner's identity. */
528 struct filedesc *p_fd; /* (b) Ptr to open files structure. */
529 struct filedesc_to_leader *p_fdtol; /* (b) Ptr to tracking node */
530 /* Accumulated stats for all KSEs? */
531 struct pstats *p_stats; /* (b) Accounting/statistics (CPU). */
532 struct plimit *p_limit; /* (c*) Process limits. */
533 struct vm_object *p_upages_obj; /* (a) Upages object. */
534 struct sigacts *p_sigacts; /* (x) Signal actions, state (CPU). */
535
536 /*struct ksegrp p_ksegrp;
537 struct kse p_kse; */
538
539 /*
540 * The following don't make too much sense..
541 * See the td_ or ke_ versions of the same flags
542 */
543 int p_flag; /* (c) P_* flags. */
544 int p_sflag; /* (j) PS_* flags. */
545 enum {
546 PRS_NEW = 0, /* In creation */
547 PRS_NORMAL, /* KSEs can be run. */
548 PRS_ZOMBIE
549 } p_state; /* (j/c) S* process status. */
550 pid_t p_pid; /* (b) Process identifier. */
551 LIST_ENTRY(proc) p_hash; /* (d) Hash chain. */
552 LIST_ENTRY(proc) p_pglist; /* (g + e) List of processes in pgrp. */
553 struct proc *p_pptr; /* (c + e) Pointer to parent process. */
554 LIST_ENTRY(proc) p_sibling; /* (e) List of sibling processes. */
555 LIST_HEAD(, proc) p_children; /* (e) Pointer to list of children. */
556 struct mtx p_mtx; /* (n) Lock for this struct. */
557
558 /* The following fields are all zeroed upon creation in fork. */
559 #define p_startzero p_oppid
560 pid_t p_oppid; /* (c + e) Save ppid in ptrace. XXX */
561 struct vmspace *p_vmspace; /* (b) Address space. */
562 u_int p_swtime; /* (j) Time swapped in or out. */
563 struct itimerval p_realtimer; /* (c) Alarm timer. */
564 struct bintime p_runtime; /* (j) Real time. */
565 u_int64_t p_uu; /* (j) Previous user time in usec. */
566 u_int64_t p_su; /* (j) Previous system time in usec. */
567 u_int64_t p_iu; /* (j) Previous intr time in usec. */
568 u_int64_t p_uticks; /* (j) Statclock hits in user mode. */
569 u_int64_t p_sticks; /* (j) Statclock hits in system mode. */
570 u_int64_t p_iticks; /* (j) Statclock hits in intr. */
571 int p_profthreads; /* (c) Num threads in addupc_task. */
572 int p_maxthrwaits; /* (c) Max threads num waiters */
573 int p_traceflag; /* (o) Kernel trace points. */
574 struct vnode *p_tracevp; /* (c + o) Trace to vnode. */
575 struct ucred *p_tracecred; /* (o) Credentials to trace with. */
576 struct vnode *p_textvp; /* (b) Vnode of executable. */
577 sigset_t p_siglist; /* (c) Sigs not delivered to a td. */
578 char p_lock; /* (c) Proclock (prevent swap) count. */
579 struct klist p_klist; /* (c) Knotes attached to this proc. */
580 struct sigiolst p_sigiolst; /* (c) List of sigio sources. */
581 int p_sigparent; /* (c) Signal to parent on exit. */
582 int p_sig; /* (n) For core dump/debugger XXX. */
583 u_long p_code; /* (n) For core dump/debugger XXX. */
584 u_int p_stops; /* (c) Stop event bitmask. */
585 u_int p_stype; /* (c) Stop event type. */
586 char p_step; /* (c) Process is stopped. */
587 u_char p_pfsflags; /* (c) Procfs flags. */
588 struct nlminfo *p_nlminfo; /* (?) Only used by/for lockd. */
589 void *p_aioinfo; /* (?) ASYNC I/O info. */
590 struct thread *p_singlethread;/* (c + j) If single threading this is it */
591 int p_suspcount; /* (c) # threads in suspended mode */
592 /* End area that is zeroed on creation. */
593 #define p_endzero p_sigstk
594
595 /* The following fields are all copied upon creation in fork. */
596 #define p_startcopy p_endzero
597 stack_t p_sigstk; /* (c) Stack ptr and on-stack flag. */
598 u_int p_magic; /* (b) Magic number. */
599 char p_comm[MAXCOMLEN + 1]; /* (b) Process name. */
600 struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */
601 struct sysentvec *p_sysent; /* (b) Syscall dispatch info. */
602 struct pargs *p_args; /* (c) Process arguments. */
603 rlim_t p_cpulimit; /* (j) Current CPU limit in seconds. */
604 /* End area that is copied on creation. */
605 #define p_endcopy p_xstat
606
607 u_short p_xstat; /* (c) Exit status; also stop sig. */
608 int p_numthreads; /* (j) Number of threads. */
609 int p_numksegrps; /* (?) number of ksegrps */
610 struct mdproc p_md; /* Any machine-dependent fields. */
611 struct callout p_itcallout; /* (h + c) Interval timer callout. */
612 struct user *p_uarea; /* (k) Kernel VA of u-area (CPU). */
613 u_short p_acflag; /* (c) Accounting flags. */
614 struct rusage *p_ru; /* (a) Exit information. XXX */
615 struct proc *p_peers; /* (r) */
616 struct proc *p_leader; /* (b) */
617 void *p_emuldata; /* (c) Emulator state data. */
618 struct label *p_label; /* (*) Proc (not subject) MAC label. */
619 struct p_sched *p_sched; /* (*) Scheduler-specific data. */
620 };
621
622 #define p_rlimit p_limit->pl_rlimit
623 #define p_session p_pgrp->pg_session
624 #define p_pgid p_pgrp->pg_id
625
626 #define NOCPU 0xff /* For when we aren't on a CPU. (SMP) */
627
628 /* Status values (p_stat). */
629
630 /* These flags are kept in p_flag. */
631 #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */
632 #define P_CONTROLT 0x00002 /* Has a controlling terminal. */
633 #define P_KTHREAD 0x00004 /* Kernel thread. (*)*/
634 #define P_NOLOAD 0x00008 /* Ignore during load avg calculations. */
635 #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */
636 #define P_PROFIL 0x00020 /* Has started profiling. */
637 #define P_STOPPROF 0x00040 /* Has thread in requesting to stop prof */
638 #define P_SUGID 0x00100 /* Had set id privileges since last exec. */
639 #define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */
640 #define P_SINGLE_EXIT 0x00400 /* Threads suspending should exit, not wait. */
641 #define P_TRACED 0x00800 /* Debugged process being traced. */
642 #define P_WAITED 0x01000 /* Someone is waiting for us. */
643 #define P_WEXIT 0x02000 /* Working on exiting. */
644 #define P_EXEC 0x04000 /* Process called exec. */
645 #define P_SA 0x08000 /* Using scheduler activations. */
646 #define P_CONTINUED 0x10000 /* Proc has continued from a stopped state. */
647 #define P_STOPPED_SIG 0x20000 /* Stopped due to SIGSTOP/SIGTSTP. */
648 #define P_STOPPED_TRACE 0x40000 /* Stopped because of tracing. */
649 #define P_STOPPED_SINGLE 0x80000 /* Only one thread can continue */
650 /* (not to user) */
651 #define P_PROTECTED 0x100000 /* Do not kill on memory overcommit. */
652 #define P_SIGEVENT 0x200000 /* Process pending signals changed. */
653
654 #define P_JAILED 0x1000000 /* Process is in jail. */
655 #define P_ALTSTACK 0x2000000 /* Have alternate signal stack. */
656 #define P_INEXEC 0x4000000 /* Process is in execve(). */
657
658 #define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE)
659 #define P_SHOULDSTOP(p) ((p)->p_flag & P_STOPPED)
660
661 /* These flags are kept in p_sflag and are protected with sched_lock. */
662 #define PS_INMEM 0x00001 /* Loaded into memory. */
663 #define PS_XCPU 0x00002 /* Exceeded CPU limit. */
664 #define PS_ALRMPEND 0x00020 /* Pending SIGVTALRM needs to be posted. */
665 #define PS_PROFPEND 0x00040 /* Pending SIGPROF needs to be posted. */
666 #define PS_SWAPINREQ 0x00100 /* Swapin request due to wakeup. */
667 #define PS_SWAPPINGOUT 0x00200 /* Process is being swapped out. */
668 #define PS_SWAPPINGIN 0x04000 /* Process is being swapped in. */
669 #define PS_MACPEND 0x08000 /* Ast()-based MAC event pending. */
670
671 /* used only in legacy conversion code */
672 #define SIDL 1 /* Process being created by fork. */
673 #define SRUN 2 /* Currently runnable. */
674 #define SSLEEP 3 /* Sleeping on an address. */
675 #define SSTOP 4 /* Process debugging or suspension. */
676 #define SZOMB 5 /* Awaiting collection by parent. */
677 #define SWAIT 6 /* Waiting for interrupt. */
678 #define SLOCK 7 /* Blocked on a lock. */
679
680 #define P_MAGIC 0xbeefface
681
682 #ifdef _KERNEL
683
684 #ifdef MALLOC_DECLARE
685 MALLOC_DECLARE(M_PARGS);
686 MALLOC_DECLARE(M_PGRP);
687 MALLOC_DECLARE(M_SESSION);
688 MALLOC_DECLARE(M_SUBPROC);
689 MALLOC_DECLARE(M_ZOMBIE);
690 #endif
691
692 #define FOREACH_PROC_IN_SYSTEM(p) \
693 LIST_FOREACH((p), &allproc, p_list)
694 #define FOREACH_KSEGRP_IN_PROC(p, kg) \
695 TAILQ_FOREACH((kg), &(p)->p_ksegrps, kg_ksegrp)
696 #define FOREACH_THREAD_IN_GROUP(kg, td) \
697 TAILQ_FOREACH((td), &(kg)->kg_threads, td_kglist)
698 #define FOREACH_KSE_IN_GROUP(kg, ke) \
699 TAILQ_FOREACH((ke), &(kg)->kg_kseq, ke_kglist)
700 #define FOREACH_UPCALL_IN_GROUP(kg, ku) \
701 TAILQ_FOREACH((ku), &(kg)->kg_upcalls, ku_link)
702 #define FOREACH_THREAD_IN_PROC(p, td) \
703 TAILQ_FOREACH((td), &(p)->p_threads, td_plist)
704
705 /* XXXKSE the lines below should probably only be used in 1:1 code */
706 #define FIRST_THREAD_IN_PROC(p) TAILQ_FIRST(&(p)->p_threads)
707 #define FIRST_KSEGRP_IN_PROC(p) TAILQ_FIRST(&(p)->p_ksegrps)
708 #define FIRST_KSE_IN_KSEGRP(kg) TAILQ_FIRST(&(kg)->kg_kseq)
709 #define FIRST_KSE_IN_PROC(p) FIRST_KSE_IN_KSEGRP(FIRST_KSEGRP_IN_PROC(p))
710
711 /*
712 * We use process IDs <= PID_MAX; PID_MAX + 1 must also fit in a pid_t,
713 * as it is used to represent "no process group".
714 */
715 #define PID_MAX 99999
716 #define NO_PID 100000
717
718 #define SESS_LEADER(p) ((p)->p_session->s_leader == (p))
719 #define SESSHOLD(s) ((s)->s_count++)
720 #define SESSRELE(s) { \
721 if (--(s)->s_count == 0) \
722 FREE(s, M_SESSION); \
723 }
724
725 #define STOPEVENT(p, e, v) do { \
726 PROC_LOCK(p); \
727 _STOPEVENT((p), (e), (v)); \
728 PROC_UNLOCK(p); \
729 } while (0)
730 #define _STOPEVENT(p, e, v) do { \
731 PROC_LOCK_ASSERT(p, MA_OWNED); \
732 if ((p)->p_stops & (e)) \
733 stopevent((p), (e), (v)); \
734 } while (0)
735
736 /* Lock and unlock a process. */
737 #define PROC_LOCK(p) mtx_lock(&(p)->p_mtx)
738 #define PROC_TRYLOCK(p) mtx_trylock(&(p)->p_mtx)
739 #define PROC_UNLOCK(p) mtx_unlock(&(p)->p_mtx)
740 #define PROC_LOCKED(p) mtx_owned(&(p)->p_mtx)
741 #define PROC_LOCK_ASSERT(p, type) mtx_assert(&(p)->p_mtx, (type))
742
743 /* Lock and unlock a process group. */
744 #define PGRP_LOCK(pg) mtx_lock(&(pg)->pg_mtx)
745 #define PGRP_UNLOCK(pg) mtx_unlock(&(pg)->pg_mtx)
746 #define PGRP_LOCKED(pg) mtx_owned(&(pg)->pg_mtx)
747 #define PGRP_LOCK_ASSERT(pg, type) mtx_assert(&(pg)->pg_mtx, (type))
748
749 #define PGRP_LOCK_PGSIGNAL(pg) do { \
750 if ((pg) != NULL) \
751 PGRP_LOCK(pg); \
752 } while (0)
753 #define PGRP_UNLOCK_PGSIGNAL(pg) do { \
754 if ((pg) != NULL) \
755 PGRP_UNLOCK(pg); \
756 } while (0)
757
758 /* Lock and unlock a session. */
759 #define SESS_LOCK(s) mtx_lock(&(s)->s_mtx)
760 #define SESS_UNLOCK(s) mtx_unlock(&(s)->s_mtx)
761 #define SESS_LOCKED(s) mtx_owned(&(s)->s_mtx)
762 #define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type))
763
764 /* Hold process U-area in memory, normally for ptrace/procfs work. */
765 #define PHOLD(p) do { \
766 PROC_LOCK(p); \
767 _PHOLD(p); \
768 PROC_UNLOCK(p); \
769 } while (0)
770 #define _PHOLD(p) do { \
771 PROC_LOCK_ASSERT((p), MA_OWNED); \
772 (p)->p_lock++; \
773 if (((p)->p_sflag & PS_INMEM) == 0) \
774 faultin((p)); \
775 } while (0)
776
777 #define PRELE(p) do { \
778 PROC_LOCK((p)); \
779 _PRELE((p)); \
780 PROC_UNLOCK((p)); \
781 } while (0)
782 #define _PRELE(p) do { \
783 PROC_LOCK_ASSERT((p), MA_OWNED); \
784 (--(p)->p_lock); \
785 } while (0)
786
787 /* Check whether a thread is safe to be swapped out. */
788 #define thread_safetoswapout(td) (TD_IS_SLEEPING(td) || TD_IS_SUSPENDED(td))
789
790 /* Lock and unlock process arguments. */
791 #define PARGS_LOCK(p) mtx_lock(&pargs_ref_lock)
792 #define PARGS_UNLOCK(p) mtx_unlock(&pargs_ref_lock)
793
794 #define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
795 extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
796 extern u_long pidhash;
797
798 #define PGRPHASH(pgid) (&pgrphashtbl[(pgid) & pgrphash])
799 extern LIST_HEAD(pgrphashhead, pgrp) *pgrphashtbl;
800 extern u_long pgrphash;
801
802 extern struct sx allproc_lock;
803 extern struct sx proctree_lock;
804 extern struct mtx pargs_ref_lock;
805 extern struct mtx ppeers_lock;
806 extern struct proc proc0; /* Process slot for swapper. */
807 extern struct thread thread0; /* Primary thread in proc0. */
808 extern struct ksegrp ksegrp0; /* Primary ksegrp in proc0. */
809 extern struct kse kse0; /* Primary kse in proc0. */
810 extern struct vmspace vmspace0; /* VM space for proc0. */
811 extern int hogticks; /* Limit on kernel cpu hogs. */
812 extern int nprocs, maxproc; /* Current and max number of procs. */
813 extern int maxprocperuid; /* Max procs per uid. */
814 extern u_long ps_arg_cache_limit;
815 extern int ps_argsopen;
816 extern int sched_quantum; /* Scheduling quantum in ticks. */
817
818 LIST_HEAD(proclist, proc);
819 TAILQ_HEAD(procqueue, proc);
820 TAILQ_HEAD(threadqueue, thread);
821 extern struct proclist allproc; /* List of all processes. */
822 extern struct proclist zombproc; /* List of zombie processes. */
823 extern struct proc *initproc, *pageproc; /* Process slots for init, pager. */
824 extern struct proc *updateproc; /* Process slot for syncer (sic). */
825
826 extern struct uma_zone *proc_zone;
827
828 extern int lastpid;
829
830 struct proc *pfind(pid_t); /* Find process by id. */
831 struct pgrp *pgfind(pid_t); /* Find process group by id. */
832 struct proc *zpfind(pid_t); /* Find zombie process by id. */
833
834 void adjustrunqueue(struct thread *, int newpri);
835 void ast(struct trapframe *framep);
836 struct thread *choosethread(void);
837 int cr_cansignal(struct ucred *cred, struct proc *proc, int signum);
838 int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp, struct session *sess);
839 int enterthispgrp(struct proc *p, struct pgrp *pgrp);
840 void faultin(struct proc *p);
841 void fixjobc(struct proc *p, struct pgrp *pgrp, int entering);
842 int fork1(struct thread *, int, int, struct proc **);
843 void fork_exit(void (*)(void *, struct trapframe *), void *,
844 struct trapframe *);
845 void fork_return(struct thread *, struct trapframe *);
846 int inferior(struct proc *p);
847 int leavepgrp(struct proc *p);
848 void mi_switch(void);
849 int p_candebug(struct thread *td, struct proc *p);
850 int p_cansee(struct thread *td, struct proc *p);
851 int p_cansched(struct thread *td, struct proc *p);
852 int p_cansignal(struct thread *td, struct proc *p, int signum);
853 struct pargs *pargs_alloc(int len);
854 void pargs_drop(struct pargs *pa);
855 void pargs_free(struct pargs *pa);
856 void pargs_hold(struct pargs *pa);
857 void procinit(void);
858 void threadinit(void);
859 void proc_linkup(struct proc *p, struct ksegrp *kg,
860 struct kse *ke, struct thread *td);
861 void proc_reparent(struct proc *child, struct proc *newparent);
862 int securelevel_ge(struct ucred *cr, int level);
863 int securelevel_gt(struct ucred *cr, int level);
864 void setrunnable(struct thread *);
865 void setrunqueue(struct thread *);
866 void setsugid(struct proc *p);
867 int sigonstack(size_t sp);
868 void sleepinit(void);
869 void stopevent(struct proc *, u_int, u_int);
870 void cpu_idle(void);
871 extern void (*cpu_idle_hook)(void); /* Hook to machdep CPU idler. */
872 void cpu_switch(struct thread *old, struct thread *new);
873 void cpu_throw(struct thread *old, struct thread *new) __dead2;
874 void unsleep(struct thread *);
875 void userret(struct thread *, struct trapframe *, u_int);
876
877 void cpu_exit(struct thread *);
878 void cpu_sched_exit(struct thread *);
879 void exit1(struct thread *, int) __dead2;
880 void cpu_fork(struct thread *, struct proc *, struct thread *, int);
881 void cpu_set_fork_handler(struct thread *, void (*)(void *), void *);
882
883 /* New in KSE. */
884 struct ksegrp *ksegrp_alloc(void);
885 void ksegrp_free(struct ksegrp *kg);
886 void ksegrp_stash(struct ksegrp *kg);
887 struct kse *kse_alloc(void);
888 void kse_free(struct kse *ke);
889 void kse_stash(struct kse *ke);
890 void cpu_set_upcall(struct thread *td, struct thread *td0);
891 void cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku);
892 void cpu_thread_clean(struct thread *);
893 void cpu_thread_exit(struct thread *);
894 void cpu_thread_setup(struct thread *td);
895 void cpu_thread_siginfo(int sig, u_long code, siginfo_t *si);
896 void cpu_thread_swapin(struct thread *);
897 void cpu_thread_swapout(struct thread *);
898 void kse_reassign(struct kse *ke);
899 void kse_link(struct kse *ke, struct ksegrp *kg);
900 void kse_unlink(struct kse *ke);
901 void ksegrp_link(struct ksegrp *kg, struct proc *p);
902 void ksegrp_unlink(struct ksegrp *kg);
903 void thread_signal_add(struct thread *td, int sig);
904 struct thread *thread_alloc(void);
905 void thread_exit(void) __dead2;
906 int thread_export_context(struct thread *td, int willexit);
907 void thread_free(struct thread *td);
908 void thread_link(struct thread *td, struct ksegrp *kg);
909 void thread_reap(void);
910 struct thread *thread_schedule_upcall(struct thread *td, struct kse_upcall *ku);
911 int thread_single(int how);
912 #define SINGLE_NO_EXIT 0 /* values for 'how' */
913 #define SINGLE_EXIT 1
914 void thread_single_end(void);
915 void thread_stash(struct thread *td);
916 int thread_suspend_check(int how);
917 void thread_suspend_one(struct thread *td);
918 void thread_unlink(struct thread *td);
919 void thread_unsuspend(struct proc *p);
920 void thread_unsuspend_one(struct thread *td);
921 int thread_userret(struct thread *td, struct trapframe *frame);
922 void thread_user_enter(struct proc *p, struct thread *td);
923 void thread_wait(struct proc *p);
924 int thread_statclock(int user);
925 struct kse_upcall *upcall_alloc(void);
926 void upcall_free(struct kse_upcall *ku);
927 void upcall_link(struct kse_upcall *ku, struct ksegrp *kg);
928 void upcall_unlink(struct kse_upcall *ku);
929 void upcall_remove(struct thread *td);
930 void upcall_stash(struct kse_upcall *ke);
931 void thread_sanity_check(struct thread *td, char *);
932 void thread_stopped(struct proc *p);
933 void thread_switchout(struct thread *td);
934 void thr_exit1(void);
935 #endif /* _KERNEL */
936
937 #endif /* !_SYS_PROC_H_ */
Cache object: b4b112eb6126e85a122cd9b858c15969
|