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