Print this page
3625 we only need one thread_create_intr
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/proc.h
+++ new/usr/src/uts/common/sys/proc.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 27 /* All Rights Reserved */
28 28
29 29 #ifndef _SYS_PROC_H
30 30 #define _SYS_PROC_H
31 31
32 32 #include <sys/time.h>
33 33 #include <sys/thread.h>
34 34 #include <sys/cred.h>
35 35 #include <sys/user.h>
36 36 #include <sys/watchpoint.h>
37 37 #include <sys/timer.h>
38 38 #if defined(__x86)
39 39 #include <sys/tss.h>
40 40 #include <sys/segments.h>
41 41 #endif
42 42 #include <sys/utrap.h>
43 43 #include <sys/model.h>
44 44 #include <sys/refstr.h>
45 45 #include <sys/avl.h>
46 46 #include <sys/rctl.h>
47 47 #include <sys/list.h>
48 48 #include <sys/avl.h>
49 49 #include <sys/door_impl.h>
50 50
51 51 #ifdef __cplusplus
52 52 extern "C" {
53 53 #endif
54 54
55 55 /*
56 56 * Profile arguments.
57 57 */
58 58 struct prof {
59 59 void *pr_base; /* buffer base */
60 60 uintptr_t pr_off; /* pc offset */
61 61 size_t pr_size; /* buffer size */
62 62 uint32_t pr_scale; /* pc scaling */
63 63 long pr_samples; /* sample count */
64 64 };
65 65
66 66 /*
67 67 * An lwp directory entry.
68 68 * If le_thread != NULL, this is an active lwp.
69 69 * If le_thread == NULL, this is an unreaped zombie lwp.
70 70 */
71 71 typedef struct lwpent {
72 72 kthread_t *le_thread; /* the active lwp, NULL if zombie */
73 73 id_t le_lwpid; /* its lwpid (t->t_tid) */
74 74 uint16_t le_waiters; /* total number of lwp_wait()ers */
75 75 uint16_t le_dwaiters; /* number that are daemons */
76 76 clock_t le_start; /* start time of this lwp */
77 77 struct vnode *le_trace; /* pointer to /proc lwp vnode */
78 78 } lwpent_t;
79 79
80 80 typedef struct pctxop {
81 81 void (*save_op)(void *); /* function to invoke to save ctx */
82 82 void (*restore_op)(void *); /* function to invoke to restore ctx */
83 83 void (*fork_op)(void *, void *); /* invoke to fork context */
84 84 void (*exit_op)(void *); /* invoked during process exit */
85 85 void (*free_op)(void *, int); /* function which frees the context */
86 86 void *arg; /* argument to above functions */
87 87 struct pctxop *next; /* next pcontext ops */
88 88 } pctxop_t;
89 89
90 90 /*
91 91 * Elements of the lwp directory, p->p_lwpdir[].
92 92 *
93 93 * We allocate lwp directory entries separately from lwp directory
94 94 * elements because the lwp directory must be allocated as an array.
95 95 * The number of lwps can grow quite large and we want to keep the
96 96 * size of the kmem_alloc()d directory as small as possible.
97 97 *
98 98 * If ld_entry == NULL, the entry is free and is on the free list,
99 99 * p->p_lwpfree, linked through ld_next. If ld_entry != NULL, the
100 100 * entry is used and ld_next is the thread-id hash link pointer.
101 101 */
102 102 typedef struct lwpdir {
103 103 struct lwpdir *ld_next; /* hash chain or free list */
104 104 struct lwpent *ld_entry; /* lwp directory entry */
105 105 } lwpdir_t;
106 106
107 107 /*
108 108 * Element of the p_tidhash thread-id (lwpid) hash table.
109 109 */
110 110 typedef struct tidhash {
111 111 kmutex_t th_lock;
112 112 lwpdir_t *th_list;
113 113 } tidhash_t;
114 114
115 115 /*
116 116 * Retired tidhash hash tables.
117 117 */
118 118 typedef struct ret_tidhash {
119 119 struct ret_tidhash *rth_next;
120 120 tidhash_t *rth_tidhash;
121 121 uint_t rth_tidhash_sz;
122 122 } ret_tidhash_t;
123 123
124 124 struct pool;
125 125 struct task;
126 126 struct zone;
127 127 struct brand;
128 128 struct corectl_path;
129 129 struct corectl_content;
130 130
131 131 /*
132 132 * One structure allocated per active process. It contains all
133 133 * data needed about the process while the process may be swapped
134 134 * out. Other per-process data (user.h) is also inside the proc structure.
135 135 * Lightweight-process data (lwp.h) and the kernel stack may be swapped out.
136 136 */
137 137 typedef struct proc {
138 138 /*
139 139 * Fields requiring no explicit locking
140 140 */
141 141 struct vnode *p_exec; /* pointer to a.out vnode */
142 142 struct as *p_as; /* process address space pointer */
143 143 struct plock *p_lockp; /* ptr to proc struct's mutex lock */
144 144 kmutex_t p_crlock; /* lock for p_cred */
145 145 struct cred *p_cred; /* process credentials */
146 146 /*
147 147 * Fields protected by pidlock
148 148 */
149 149 int p_swapcnt; /* number of swapped out lwps */
150 150 char p_stat; /* status of process */
151 151 char p_wcode; /* current wait code */
152 152 ushort_t p_pidflag; /* flags protected only by pidlock */
153 153 int p_wdata; /* current wait return value */
154 154 pid_t p_ppid; /* process id of parent */
155 155 struct proc *p_link; /* forward link */
156 156 struct proc *p_parent; /* ptr to parent process */
157 157 struct proc *p_child; /* ptr to first child process */
158 158 struct proc *p_sibling; /* ptr to next sibling proc on chain */
159 159 struct proc *p_psibling; /* ptr to prev sibling proc on chain */
160 160 struct proc *p_sibling_ns; /* prt to siblings with new state */
161 161 struct proc *p_child_ns; /* prt to children with new state */
162 162 struct proc *p_next; /* active chain link next */
163 163 struct proc *p_prev; /* active chain link prev */
164 164 struct proc *p_nextofkin; /* gets accounting info at exit */
165 165 struct proc *p_orphan;
166 166 struct proc *p_nextorph;
167 167 struct proc *p_pglink; /* process group hash chain link next */
168 168 struct proc *p_ppglink; /* process group hash chain link prev */
169 169 struct sess *p_sessp; /* session information */
170 170 struct pid *p_pidp; /* process ID info */
171 171 struct pid *p_pgidp; /* process group ID info */
172 172 /*
173 173 * Fields protected by p_lock
174 174 */
175 175 kcondvar_t p_cv; /* proc struct's condition variable */
176 176 kcondvar_t p_flag_cv;
177 177 kcondvar_t p_lwpexit; /* waiting for some lwp to exit */
178 178 kcondvar_t p_holdlwps; /* process is waiting for its lwps */
179 179 /* to to be held. */
180 180 uint_t p_proc_flag; /* /proc-related flags */
181 181 uint_t p_flag; /* protected while set. */
182 182 /* flags defined below */
183 183 clock_t p_utime; /* user time, this process */
184 184 clock_t p_stime; /* system time, this process */
185 185 clock_t p_cutime; /* sum of children's user time */
186 186 clock_t p_cstime; /* sum of children's system time */
187 187 avl_tree_t *p_segacct; /* System V shared segment list */
188 188 avl_tree_t *p_semacct; /* System V semaphore undo list */
189 189 caddr_t p_bssbase; /* base addr of last bss below heap */
190 190 caddr_t p_brkbase; /* base addr of heap */
191 191 size_t p_brksize; /* heap size in bytes */
192 192 uint_t p_brkpageszc; /* preferred heap max page size code */
193 193 /*
194 194 * Per process signal stuff.
195 195 */
196 196 k_sigset_t p_sig; /* signals pending to this process */
197 197 k_sigset_t p_extsig; /* signals sent from another contract */
198 198 k_sigset_t p_ignore; /* ignore when generated */
199 199 k_sigset_t p_siginfo; /* gets signal info with signal */
200 200 struct sigqueue *p_sigqueue; /* queued siginfo structures */
201 201 struct sigqhdr *p_sigqhdr; /* hdr to sigqueue structure pool */
202 202 struct sigqhdr *p_signhdr; /* hdr to signotify structure pool */
203 203 uchar_t p_stopsig; /* jobcontrol stop signal */
204 204
205 205 /*
206 206 * Special per-process flag when set will fix misaligned memory
207 207 * references.
208 208 */
209 209 char p_fixalignment;
210 210
211 211 /*
212 212 * Per process lwp and kernel thread stuff
213 213 */
214 214 id_t p_lwpid; /* most recently allocated lwpid */
215 215 int p_lwpcnt; /* number of lwps in this process */
216 216 int p_lwprcnt; /* number of not stopped lwps */
217 217 int p_lwpdaemon; /* number of TP_DAEMON lwps */
218 218 int p_lwpwait; /* number of lwps in lwp_wait() */
219 219 int p_lwpdwait; /* number of daemons in lwp_wait() */
220 220 int p_zombcnt; /* number of zombie lwps */
221 221 kthread_t *p_tlist; /* circular list of threads */
222 222 lwpdir_t *p_lwpdir; /* thread (lwp) directory */
223 223 lwpdir_t *p_lwpfree; /* p_lwpdir free list */
224 224 tidhash_t *p_tidhash; /* tid (lwpid) lookup hash table */
225 225 uint_t p_lwpdir_sz; /* number of p_lwpdir[] entries */
226 226 uint_t p_tidhash_sz; /* number of p_tidhash[] entries */
227 227 ret_tidhash_t *p_ret_tidhash; /* retired tidhash hash tables */
228 228 uint64_t p_lgrpset; /* unprotected hint of set of lgrps */
229 229 /* on which process has threads */
230 230 volatile lgrp_id_t p_t1_lgrpid; /* main's thread lgroup id */
231 231 volatile lgrp_id_t p_tr_lgrpid; /* text replica's lgroup id */
232 232 #if defined(_LP64)
233 233 uintptr_t p_lgrpres2; /* reserved for lgrp migration */
234 234 #endif
235 235 /*
236 236 * /proc (process filesystem) debugger interface stuff.
237 237 */
238 238 k_sigset_t p_sigmask; /* mask of traced signals (/proc) */
239 239 k_fltset_t p_fltmask; /* mask of traced faults (/proc) */
240 240 struct vnode *p_trace; /* pointer to primary /proc vnode */
241 241 struct vnode *p_plist; /* list of /proc vnodes for process */
242 242 kthread_t *p_agenttp; /* thread ptr for /proc agent lwp */
243 243 avl_tree_t p_warea; /* list of watched areas */
244 244 avl_tree_t p_wpage; /* remembered watched pages (vfork) */
245 245 watched_page_t *p_wprot; /* pages that need to have prot set */
246 246 int p_mapcnt; /* number of active pr_mappage()s */
247 247 kmutex_t p_maplock; /* lock for pr_mappage() */
248 248 struct proc *p_rlink; /* linked list for server */
249 249 kcondvar_t p_srwchan_cv;
250 250 size_t p_stksize; /* process stack size in bytes */
251 251 uint_t p_stkpageszc; /* preferred stack max page size code */
252 252
253 253 /*
254 254 * Microstate accounting, resource usage, and real-time profiling
255 255 */
256 256 hrtime_t p_mstart; /* hi-res process start time */
257 257 hrtime_t p_mterm; /* hi-res process termination time */
258 258 hrtime_t p_mlreal; /* elapsed time sum over defunct lwps */
259 259 hrtime_t p_acct[NMSTATES]; /* microstate sum over defunct lwps */
260 260 hrtime_t p_cacct[NMSTATES]; /* microstate sum over child procs */
261 261 struct lrusage p_ru; /* lrusage sum over defunct lwps */
262 262 struct lrusage p_cru; /* lrusage sum over child procs */
263 263 struct itimerval p_rprof_timer; /* ITIMER_REALPROF interval timer */
264 264 uintptr_t p_rprof_cyclic; /* ITIMER_REALPROF cyclic */
265 265 uint_t p_defunct; /* number of defunct lwps */
266 266 /*
267 267 * profiling. A lock is used in the event of multiple lwp's
268 268 * using the same profiling base/size.
269 269 */
270 270 kmutex_t p_pflock; /* protects user profile arguments */
271 271 struct prof p_prof; /* profile arguments */
272 272
273 273 /*
274 274 * Doors.
275 275 */
276 276 door_pool_t p_server_threads; /* common thread pool */
277 277 struct door_node *p_door_list; /* active doors */
278 278 struct door_node *p_unref_list;
279 279 kcondvar_t p_unref_cv;
280 280 char p_unref_thread; /* unref thread created */
281 281
282 282 /*
283 283 * Kernel probes
284 284 */
285 285 uchar_t p_tnf_flags;
286 286
287 287 /*
288 288 * Solaris Audit
289 289 */
290 290 struct p_audit_data *p_audit_data; /* per process audit structure */
291 291
292 292 pctxop_t *p_pctx;
293 293
294 294 #if defined(__x86)
295 295 /*
296 296 * LDT support.
297 297 */
298 298 kmutex_t p_ldtlock; /* protects the following fields */
299 299 user_desc_t *p_ldt; /* Pointer to private LDT */
300 300 system_desc_t p_ldt_desc; /* segment descriptor for private LDT */
301 301 ushort_t p_ldtlimit; /* highest selector used */
302 302 #endif
303 303 size_t p_swrss; /* resident set size before last swap */
304 304 struct aio *p_aio; /* pointer to async I/O struct */
305 305 struct itimer **p_itimer; /* interval timers */
306 306 timeout_id_t p_alarmid; /* alarm's timeout id */
307 307 caddr_t p_usrstack; /* top of the process stack */
308 308 uint_t p_stkprot; /* stack memory protection */
309 309 uint_t p_datprot; /* data memory protection */
310 310 model_t p_model; /* data model determined at exec time */
311 311 struct lwpchan_data *p_lcp; /* lwpchan cache */
312 312 kmutex_t p_lcp_lock; /* protects assignments to p_lcp */
313 313 utrap_handler_t *p_utraps; /* pointer to user trap handlers */
314 314 struct corectl_path *p_corefile; /* pattern for core file */
315 315 struct task *p_task; /* our containing task */
316 316 struct proc *p_taskprev; /* ptr to previous process in task */
317 317 struct proc *p_tasknext; /* ptr to next process in task */
318 318 kmutex_t p_sc_lock; /* protects p_pagep */
319 319 struct sc_page_ctl *p_pagep; /* list of process's shared pages */
320 320 struct rctl_set *p_rctls; /* resource controls for this process */
321 321 rlim64_t p_stk_ctl; /* currently enforced stack size */
322 322 rlim64_t p_fsz_ctl; /* currently enforced file size */
323 323 rlim64_t p_vmem_ctl; /* currently enforced addr-space size */
324 324 rlim64_t p_fno_ctl; /* currently enforced file-desc limit */
325 325 pid_t p_ancpid; /* ancestor pid, used by exacct */
326 326 struct itimerval p_realitimer; /* real interval timer */
327 327 timeout_id_t p_itimerid; /* real interval timer's timeout id */
328 328 struct corectl_content *p_content; /* content of core file */
329 329
330 330 avl_tree_t p_ct_held; /* held contracts */
331 331 struct ct_equeue **p_ct_equeue; /* process-type event queues */
332 332
333 333 struct cont_process *p_ct_process; /* process contract */
334 334 list_node_t p_ct_member; /* process contract membership */
335 335 sigqueue_t *p_killsqp; /* sigqueue pointer for SIGKILL */
336 336
337 337 int p_dtrace_probes; /* are there probes for this proc? */
338 338 uint64_t p_dtrace_count; /* number of DTrace tracepoints */
339 339 /* (protected by P_PR_LOCK) */
340 340 void *p_dtrace_helpers; /* DTrace helpers, if any */
341 341 struct pool *p_pool; /* pointer to containing pool */
342 342 kcondvar_t p_poolcv; /* synchronization with pools */
343 343 uint_t p_poolcnt; /* # threads inside pool barrier */
344 344 uint_t p_poolflag; /* pool-related flags (see below) */
345 345 uintptr_t p_portcnt; /* event ports counter */
346 346 struct zone *p_zone; /* zone in which process lives */
347 347 struct vnode *p_execdir; /* directory that p_exec came from */
348 348 struct brand *p_brand; /* process's brand */
349 349 void *p_brand_data; /* per-process brand state */
350 350
351 351 /* additional lock to protect p_sessp (but not its contents) */
352 352 kmutex_t p_splock;
353 353 rctl_qty_t p_locked_mem; /* locked memory charged to proc */
354 354 /* protected by p_lock */
355 355 rctl_qty_t p_crypto_mem; /* /dev/crypto memory charged to proc */
356 356 /* protected by p_lock */
357 357 clock_t p_ttime; /* buffered task time */
358 358
359 359 /*
360 360 * The user structure
361 361 */
362 362 struct user p_user; /* (see sys/user.h) */
363 363 } proc_t;
364 364
365 365 #define PROC_T /* headers relying on proc_t are OK */
366 366
367 367 #ifdef _KERNEL
368 368
369 369 /* active process chain */
370 370
371 371 extern proc_t *practive;
372 372
373 373 /* Well known processes */
374 374
375 375 extern proc_t *proc_sched; /* memory scheduler */
376 376 extern proc_t *proc_init; /* init */
377 377 extern proc_t *proc_pageout; /* pageout daemon */
378 378 extern proc_t *proc_fsflush; /* filesystem sync-er */
379 379
380 380 #endif /* _KERNEL */
381 381
382 382 /*
383 383 * Stuff to keep track of the number of processes each uid has.
384 384 * It is tracked on a per-zone basis; that is, if users in different
385 385 * zones have the same uid, they are tracked separately.
386 386 *
387 387 * A structure is allocated when a new <uid,zoneid> pair shows up
388 388 * There is a hash to find each structure.
389 389 */
390 390 struct upcount {
391 391 struct upcount *up_next;
392 392 uid_t up_uid;
393 393 zoneid_t up_zoneid;
394 394 uint_t up_count;
395 395 };
396 396
397 397 /* process ID info */
398 398
399 399 struct pid {
400 400 unsigned int pid_prinactive :1;
401 401 unsigned int pid_pgorphaned :1;
402 402 unsigned int pid_padding :6; /* used to be pid_ref, now an int */
403 403 unsigned int pid_prslot :24;
404 404 pid_t pid_id;
405 405 struct proc *pid_pglink;
406 406 struct proc *pid_pgtail;
407 407 struct pid *pid_link;
408 408 uint_t pid_ref;
409 409 };
410 410
411 411 #define p_pgrp p_pgidp->pid_id
412 412 #define p_pid p_pidp->pid_id
413 413 #define p_slot p_pidp->pid_prslot
414 414 #define p_detached p_pgidp->pid_pgorphaned
415 415
416 416 #define PID_HOLD(pidp) ASSERT(MUTEX_HELD(&pidlock)); \
417 417 ++(pidp)->pid_ref;
418 418 #define PID_RELE(pidp) ASSERT(MUTEX_HELD(&pidlock)); \
419 419 (pidp)->pid_ref > 1 ? \
420 420 --(pidp)->pid_ref : pid_rele(pidp);
421 421
422 422 /*
423 423 * Structure containing persistent process lock. The structure and
424 424 * macro allow "mutex_enter(&p->p_lock)" to continue working.
425 425 */
426 426 struct plock {
427 427 kmutex_t pl_lock;
428 428 };
429 429 #define p_lock p_lockp->pl_lock
430 430
431 431 #ifdef _KERNEL
432 432 extern proc_t p0; /* process 0 */
433 433 extern struct plock p0lock; /* p0's plock */
434 434 extern struct pid pid0; /* p0's pid */
435 435
436 436 /* pid_allocate() flags */
437 437 #define PID_ALLOC_PROC 0x0001 /* assign a /proc slot as well */
438 438
439 439 #endif /* _KERNEL */
440 440
441 441 /* stat codes */
442 442
443 443 #define SSLEEP 1 /* awaiting an event */
444 444 #define SRUN 2 /* runnable */
445 445 #define SZOMB 3 /* process terminated but not waited for */
446 446 #define SSTOP 4 /* process stopped by debugger */
447 447 #define SIDL 5 /* intermediate state in process creation */
448 448 #define SONPROC 6 /* process is being run on a processor */
449 449 #define SWAIT 7 /* process is waiting to become runnable */
450 450
451 451 /* p_pidflag codes */
452 452 #define CLDPEND 0x0001 /* have yet to post a SIGCHLD to the parent */
453 453 #define CLDCONT 0x0002 /* child has notified parent of CLD_CONTINUED */
454 454 #define CLDNOSIGCHLD 0x0004 /* do not post SIGCHLD when child terminates */
455 455 #define CLDWAITPID 0x0008 /* only waitid(P_PID, pid) can reap the child */
456 456
457 457 /* p_proc_flag codes -- these flags are mostly private to /proc */
458 458 #define P_PR_TRACE 0x0001 /* signal, fault or syscall tracing via /proc */
459 459 #define P_PR_PTRACE 0x0002 /* ptrace() compatibility mode */
460 460 #define P_PR_FORK 0x0004 /* child inherits tracing flags */
461 461 #define P_PR_LOCK 0x0008 /* process locked by /proc */
462 462 #define P_PR_ASYNC 0x0010 /* asynchronous stopping via /proc */
463 463 #define P_PR_EXEC 0x0020 /* process is in exec() */
464 464 #define P_PR_BPTADJ 0x0040 /* adjust pc on breakpoint trap */
465 465 #define P_PR_RUNLCL 0x0080 /* set process running on last /proc close */
466 466 #define P_PR_KILLCL 0x0100 /* kill process on last /proc close */
467 467
468 468 /*
469 469 * p_flag codes
470 470 *
471 471 * note that two of these flags, SMSACCT and SSYS, are exported to /proc's
472 472 * psinfo_t.p_flag field. Historically, all were, but since they are
473 473 * implementation dependant, we only export the ones people have come to
474 474 * rely upon. Hence, the bit positions of SSYS and SMSACCT should not be
475 475 * altered.
476 476 */
477 477 #define SSYS 0x00000001 /* system (resident) process */
478 478 #define SEXITING 0x00000002 /* process is exiting */
479 479 #define SITBUSY 0x00000004 /* setitimer(ITIMER_REAL) in progress */
480 480 #define SFORKING 0x00000008 /* tells called functions that we're forking */
481 481 #define SWATCHOK 0x00000010 /* proc in acceptable state for watchpoints */
482 482 #define SKILLED 0x00000100 /* SIGKILL has been posted to the process */
483 483 #define SSCONT 0x00000200 /* SIGCONT has been posted to the process */
484 484 #define SZONETOP 0x00000400 /* process has no valid PPID in its zone */
485 485 #define SEXTKILLED 0x00000800 /* SKILLED is from another contract */
486 486 #define SUGID 0x00002000 /* process was result of set[ug]id exec */
487 487 #define SEXECED 0x00004000 /* this process has execed */
488 488 #define SJCTL 0x00010000 /* SIGCHLD sent when children stop/continue */
489 489 #define SNOWAIT 0x00020000 /* children never become zombies */
490 490 #define SVFORK 0x00040000 /* child of vfork that has not yet exec'd */
491 491 #define SVFWAIT 0x00080000 /* parent of vfork waiting for child to exec */
492 492 #define SEXITLWPS 0x00100000 /* have lwps exit within the process */
493 493 #define SHOLDFORK 0x00200000 /* hold lwps where they're cloneable */
494 494 #define SHOLDFORK1 0x00800000 /* hold lwps in place (not cloning) */
495 495 #define SCOREDUMP 0x01000000 /* process is dumping core */
496 496 #define SMSACCT 0x02000000 /* process is keeping micro-state accounting */
497 497 #define SLWPWRAP 0x04000000 /* process has wrapped its lwp ids */
498 498 #define SAUTOLPG 0x08000000 /* kernel controls page sizes */
499 499 #define SNOCD 0x10000000 /* new creds from VSxID, do not coredump */
500 500 #define SHOLDWATCH 0x20000000 /* hold lwps for watchpoint operation */
501 501 #define SMSFORK 0x40000000 /* child inherits micro-state accounting */
502 502 #define SDOCORE 0x80000000 /* process will attempt to dump core */
503 503
504 504 /*
505 505 * p_poolflag codes
506 506 *
507 507 * These flags are used to synchronize with the pool subsystem to allow
508 508 * re-binding of processes to new pools.
509 509 */
510 510 #define PBWAIT 0x0001 /* process should wait outside fork/exec/exit */
511 511 #define PEXITED 0x0002 /* process exited and about to become zombie */
512 512
513 513 /* Macro to convert proc pointer to a user block pointer */
514 514 #define PTOU(p) (&(p)->p_user)
515 515
516 516 #define tracing(p, sig) (sigismember(&(p)->p_sigmask, sig))
517 517
518 518 /* Macro to reduce unnecessary calls to issig() */
519 519
520 520 #define ISSIG(t, why) ISSIG_FAST(t, ttolwp(t), ttoproc(t), why)
521 521
522 522 /*
523 523 * Fast version of ISSIG.
524 524 * 1. uses register pointers to lwp and proc instead of reloading them.
525 525 * 2. uses bit-wise OR of tests, since the usual case is that none of them
526 526 * are true, this saves orcc's and branches.
527 527 * 3. load the signal flags instead of using sigisempty() macro which does
528 528 * a branch to convert to boolean.
529 529 */
530 530 #define ISSIG_FAST(t, lwp, p, why) \
531 531 (ISSIG_PENDING(t, lwp, p) && issig(why))
532 532
533 533 #define ISSIG_PENDING(t, lwp, p) \
534 534 ((lwp)->lwp_cursig | \
535 535 sigcheck((p), (t)) | \
536 536 (p)->p_stopsig | \
537 537 (t)->t_dtrace_stop | \
538 538 (t)->t_dtrace_sig | \
539 539 ((t)->t_proc_flag & (TP_PRSTOP|TP_HOLDLWP|TP_CHKPT|TP_PAUSE)) | \
540 540 ((p)->p_flag & (SEXITLWPS|SKILLED|SHOLDFORK1|SHOLDWATCH)))
541 541
542 542 #define ISSTOP(sig) (u.u_signal[sig-1] == SIG_DFL && \
543 543 sigismember(&stopdefault, sig))
544 544
545 545 #define ISHOLD(p) ((p)->p_flag & SHOLDFORK)
546 546
547 547 #define MUSTRETURN(p, t) (ISHOLD(p) | (t)->t_activefd.a_stale)
548 548
549 549 /*
550 550 * Determine if there are any watchpoints active in the process.
551 551 */
552 552 #define pr_watch_active(p) (avl_numnodes(&(p)->p_warea) != 0)
553 553
554 554 /* Reasons for calling issig() */
555 555
556 556 #define FORREAL 0 /* Usual side-effects */
557 557 #define JUSTLOOKING 1 /* Don't stop the process */
558 558
559 559 /* 'what' values for stop(PR_SUSPENDED, what) */
560 560 #define SUSPEND_NORMAL 0
561 561 #define SUSPEND_PAUSE 1
562 562
563 563 /* pseudo-flag to lwp_create() */
564 564 #define NOCLASS (-1)
565 565
566 566 /* unused scheduling class ID */
567 567 #define CLASS_UNUSED (-2)
568 568
569 569 /* LWP stats updated via lwp_stats_update() */
570 570 typedef enum {
571 571 LWP_STAT_INBLK,
572 572 LWP_STAT_OUBLK,
573 573 LWP_STAT_MSGRCV,
574 574 LWP_STAT_MSGSND
575 575 } lwp_stat_id_t;
576 576
577 577 #ifdef _KERNEL
578 578
579 579 /* user profiling functions */
580 580
581 581 extern void profil_tick(uintptr_t);
582 582
583 583 /* process management functions */
584 584
585 585 extern int newproc(void (*)(), caddr_t, id_t, int, struct contract **, pid_t);
586 586 extern void vfwait(pid_t);
587 587 extern void proc_detach(proc_t *);
588 588 extern void freeproc(proc_t *);
589 589 extern void setrun(kthread_t *);
590 590 extern void setrun_locked(kthread_t *);
591 591 extern void exit(int, int);
592 592 extern int proc_exit(int, int);
593 593 extern void proc_is_exiting(proc_t *);
594 594 extern void relvm(void);
595 595 extern void add_ns(proc_t *, proc_t *);
596 596 extern void delete_ns(proc_t *, proc_t *);
597 597 extern void upcount_inc(uid_t, zoneid_t);
598 598 extern void upcount_dec(uid_t, zoneid_t);
599 599 extern int upcount_get(uid_t, zoneid_t);
600 600 #if defined(__x86)
601 601 extern selector_t setup_thrptr(proc_t *, uintptr_t);
602 602 extern void deferred_singlestep_trap(caddr_t);
603 603 #endif
604 604
605 605 extern void sigcld(proc_t *, sigqueue_t *);
606 606 extern void sigcld_delete(k_siginfo_t *);
607 607 extern void sigcld_repost(void);
608 608 extern int fsig(k_sigset_t *, kthread_t *);
609 609 extern void psig(void);
610 610 extern void stop(int, int);
611 611 extern int stop_on_fault(uint_t, k_siginfo_t *);
612 612 extern int issig(int);
613 613 extern int jobstopped(proc_t *);
614 614 extern void psignal(proc_t *, int);
615 615 extern void tsignal(kthread_t *, int);
616 616 extern void sigtoproc(proc_t *, kthread_t *, int);
617 617 extern void trapsig(k_siginfo_t *, int);
618 618 extern void realsigprof(int, int, int);
619 619 extern int eat_signal(kthread_t *, int);
620 620 extern int signal_is_blocked(kthread_t *, int);
621 621 extern int sigcheck(proc_t *, kthread_t *);
622 622 extern void sigdefault(proc_t *);
623 623
624 624 extern void pid_setmin(void);
625 625 extern pid_t pid_allocate(proc_t *, pid_t, int);
626 626 extern int pid_rele(struct pid *);
627 627 extern void pid_exit(proc_t *, struct task *);
628 628 extern void proc_entry_free(struct pid *);
629 629 extern proc_t *prfind(pid_t);
630 630 extern proc_t *prfind_zone(pid_t, zoneid_t);
631 631 extern proc_t *pgfind(pid_t);
632 632 extern proc_t *pgfind_zone(pid_t, zoneid_t);
633 633 extern proc_t *sprlock(pid_t);
634 634 extern proc_t *sprlock_zone(pid_t, zoneid_t);
635 635 extern int sprtrylock_proc(proc_t *);
636 636 extern void sprwaitlock_proc(proc_t *);
637 637 extern void sprlock_proc(proc_t *);
638 638 extern void sprunlock(proc_t *);
639 639 extern void pid_init(void);
640 640 extern proc_t *pid_entry(int);
641 641 extern int pid_slot(proc_t *);
642 642 extern void signal(pid_t, int);
643 643 extern void prsignal(struct pid *, int);
644 644 extern int uread(proc_t *, void *, size_t, uintptr_t);
645 645 extern int uwrite(proc_t *, void *, size_t, uintptr_t);
646 646
647 647 extern void pgsignal(struct pid *, int);
648 648 extern void pgjoin(proc_t *, struct pid *);
649 649 extern void pgcreate(proc_t *);
650 650 extern void pgexit(proc_t *);
651 651 extern void pgdetach(proc_t *);
652 652 extern int pgmembers(pid_t);
653 653
654 654 extern void init_mstate(kthread_t *, int);
655 655 extern int new_mstate(kthread_t *, int);
656 656 extern void restore_mstate(kthread_t *);
657 657 extern void term_mstate(kthread_t *);
658 658 extern void estimate_msacct(kthread_t *, hrtime_t);
659 659 extern void disable_msacct(proc_t *);
660 660 extern hrtime_t mstate_aggr_state(proc_t *, int);
661 661 extern hrtime_t mstate_thread_onproc_time(kthread_t *);
662 662 extern void mstate_systhread_times(kthread_t *, hrtime_t *, hrtime_t *);
663 663 extern void syscall_mstate(int, int);
664 664
665 665 extern uint_t cpu_update_pct(kthread_t *, hrtime_t);
↓ open down ↓ |
665 lines elided |
↑ open up ↑ |
666 666
667 667 extern void set_proc_pre_sys(proc_t *p);
668 668 extern void set_proc_post_sys(proc_t *p);
669 669 extern void set_proc_sys(proc_t *p);
670 670 extern void set_proc_ast(proc_t *p);
671 671 extern void set_all_proc_sys(void);
672 672 extern void set_all_zone_usr_proc_sys(zoneid_t);
673 673
674 674 /* thread function prototypes */
675 675
676 -extern kthread_t *thread_create(
677 - caddr_t stk,
678 - size_t stksize,
679 - void (*proc)(),
680 - void *arg,
681 - size_t len,
682 - proc_t *pp,
683 - int state,
684 - pri_t pri);
676 +extern kthread_t *thread_create(caddr_t, size_t, void (*)(), void *,
677 + size_t, proc_t *, int, pri_t);
685 678 extern void thread_exit(void) __NORETURN;
686 679 extern void thread_free(kthread_t *);
687 680 extern void thread_rele(kthread_t *);
688 681 extern void thread_join(kt_did_t);
689 682 extern int reaper(void);
690 683 extern void installctx(kthread_t *, void *, void (*)(), void (*)(),
691 684 void (*)(), void (*)(), void (*)(), void (*)());
692 685 extern int removectx(kthread_t *, void *, void (*)(), void (*)(),
693 686 void (*)(), void (*)(), void (*)(), void (*)());
694 687 extern void savectx(kthread_t *);
695 688 extern void restorectx(kthread_t *);
696 689 extern void forkctx(kthread_t *, kthread_t *);
697 690 extern void lwp_createctx(kthread_t *, kthread_t *);
698 691 extern void exitctx(kthread_t *);
699 692 extern void freectx(kthread_t *, int);
700 693 extern void installpctx(proc_t *, void *, void (*)(), void (*)(),
701 694 void (*)(), void (*)(), void (*)());
702 695 extern int removepctx(proc_t *, void *, void (*)(), void (*)(),
703 696 void (*)(), void (*)(), void (*)());
704 697 extern void savepctx(proc_t *);
705 698 extern void restorepctx(proc_t *);
706 699 extern void forkpctx(proc_t *, proc_t *);
707 700 extern void exitpctx(proc_t *);
708 701 extern void freepctx(proc_t *, int);
709 702 extern kthread_t *thread_unpin(void);
710 703 extern void thread_init(void);
711 704 extern void thread_load(kthread_t *, void (*)(), caddr_t, size_t);
712 705
713 706 extern void tsd_create(uint_t *, void (*)(void *));
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
714 707 extern void tsd_destroy(uint_t *);
715 708 extern void *tsd_getcreate(uint_t *, void (*)(void *), void *(*)(void));
716 709 extern void *tsd_get(uint_t);
717 710 extern int tsd_set(uint_t, void *);
718 711 extern void tsd_exit(void);
719 712 extern void *tsd_agent_get(kthread_t *, uint_t);
720 713 extern int tsd_agent_set(kthread_t *, uint_t, void *);
721 714
722 715 /* lwp function prototypes */
723 716
724 -extern kthread_t *lwp_kernel_create(proc_t *, void (*)(), void *, int, pri_t);
725 -extern klwp_t *lwp_create(
726 - void (*proc)(),
727 - caddr_t arg,
728 - size_t len,
729 - proc_t *p,
730 - int state,
731 - int pri,
732 - const k_sigset_t *smask,
733 - int cid,
734 - id_t lwpid);
717 +extern kthread_t *lwp_kernel_create(proc_t *, void (*)(), void *, int, pri_t);
718 +extern klwp_t *lwp_create(void (*)(), caddr_t, size_t, proc_t *, int, int,
719 + const k_sigset_t *, int, id_t);
735 720 extern kthread_t *idtot(proc_t *, id_t);
736 721 extern void lwp_hash_in(proc_t *, lwpent_t *, tidhash_t *, uint_t, int);
737 722 extern void lwp_hash_out(proc_t *, id_t);
738 723 extern lwpdir_t *lwp_hash_lookup(proc_t *, id_t);
739 724 extern lwpdir_t *lwp_hash_lookup_and_lock(proc_t *, id_t, kmutex_t **);
740 725 extern void lwp_create_done(kthread_t *);
741 726 extern void lwp_exit(void);
742 727 extern void lwp_pcb_exit(void);
743 728 extern void lwp_cleanup(void);
744 729 extern int lwp_suspend(kthread_t *);
745 730 extern void lwp_continue(kthread_t *);
746 731 extern void holdlwp(void);
747 732 extern void stoplwp(void);
748 733 extern int holdlwps(int);
749 734 extern int holdwatch(void);
750 735 extern void pokelwps(proc_t *);
751 736 extern void continuelwps(proc_t *);
752 737 extern int exitlwps(int);
753 738 extern void lwp_ctmpl_copy(klwp_t *, klwp_t *);
754 739 extern void lwp_ctmpl_clear(klwp_t *);
755 740 extern klwp_t *forklwp(klwp_t *, proc_t *, id_t);
756 741 extern void lwp_load(klwp_t *, gregset_t, uintptr_t);
757 742 extern void lwp_setrval(klwp_t *, int, int);
758 743 extern void lwp_forkregs(klwp_t *, klwp_t *);
759 744 extern void lwp_freeregs(klwp_t *, int);
760 745 extern caddr_t lwp_stk_init(klwp_t *, caddr_t);
761 746 extern void lwp_stk_cache_init(void);
762 747 extern void lwp_stk_fini(klwp_t *);
763 748 extern void lwp_installctx(klwp_t *);
764 749 extern void lwp_rtt(void);
765 750 extern void lwp_rtt_initial(void);
766 751 extern int lwp_setprivate(klwp_t *, int, uintptr_t);
767 752 extern void lwp_stat_update(lwp_stat_id_t, long);
768 753 extern void lwp_attach_brand_hdlrs(klwp_t *);
769 754 extern void lwp_detach_brand_hdlrs(klwp_t *);
770 755
771 756 #if defined(__sparcv9)
772 757 extern void lwp_mmodel_newlwp(void);
773 758 extern void lwp_mmodel_shared_as(caddr_t, size_t);
774 759 #define LWP_MMODEL_NEWLWP() lwp_mmodel_newlwp()
775 760 #define LWP_MMODEL_SHARED_AS(addr, sz) lwp_mmodel_shared_as((addr), (sz))
776 761 #else
777 762 #define LWP_MMODEL_NEWLWP()
778 763 #define LWP_MMODEL_SHARED_AS(addr, sz)
779 764 #endif
780 765
781 766 /*
782 767 * Signal queue function prototypes. Must be here due to header ordering
783 768 * dependencies.
784 769 */
785 770 extern void sigqfree(proc_t *);
786 771 extern void siginfofree(sigqueue_t *);
787 772 extern void sigdeq(proc_t *, kthread_t *, int, sigqueue_t **);
788 773 extern void sigdelq(proc_t *, kthread_t *, int);
789 774 extern void sigaddq(proc_t *, kthread_t *, k_siginfo_t *, int);
790 775 extern void sigaddqa(proc_t *, kthread_t *, sigqueue_t *);
791 776 extern void sigqsend(int, proc_t *, kthread_t *, sigqueue_t *);
792 777 extern void sigdupq(proc_t *, proc_t *);
793 778 extern int sigwillqueue(int, int);
794 779 extern sigqhdr_t *sigqhdralloc(size_t, uint_t);
795 780 extern sigqueue_t *sigqalloc(sigqhdr_t *);
796 781 extern void sigqhdrfree(sigqhdr_t *);
797 782 extern sigqueue_t *sigappend(k_sigset_t *, sigqueue_t *,
798 783 k_sigset_t *, sigqueue_t *);
799 784 extern sigqueue_t *sigprepend(k_sigset_t *, sigqueue_t *,
800 785 k_sigset_t *, sigqueue_t *);
801 786 extern void winfo(proc_t *, k_siginfo_t *, int);
802 787 extern int wstat(int, int);
803 788 extern int sendsig(int, k_siginfo_t *, void (*)());
804 789 #if defined(_SYSCALL32_IMPL)
805 790 extern int sendsig32(int, k_siginfo_t *, void (*)());
806 791 #endif
807 792
808 793 #endif /* _KERNEL */
809 794
810 795 #ifdef __cplusplus
811 796 }
812 797 #endif
813 798
814 799 #endif /* _SYS_PROC_H */
↓ open down ↓ |
70 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX