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