10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51455Sandrei * Common Development and Distribution License (the "License"). 61455Sandrei * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21390Sraf 220Sstevel@tonic-gate /* 2312648SSurya.Prakki@Sun.COM * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifndef _SYS_PROC_H 300Sstevel@tonic-gate #define _SYS_PROC_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/time.h> 330Sstevel@tonic-gate #include <sys/thread.h> 340Sstevel@tonic-gate #include <sys/cred.h> 350Sstevel@tonic-gate #include <sys/user.h> 360Sstevel@tonic-gate #include <sys/watchpoint.h> 370Sstevel@tonic-gate #include <sys/timer.h> 380Sstevel@tonic-gate #if defined(__x86) 390Sstevel@tonic-gate #include <sys/tss.h> 400Sstevel@tonic-gate #include <sys/segments.h> 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate #include <sys/utrap.h> 430Sstevel@tonic-gate #include <sys/model.h> 440Sstevel@tonic-gate #include <sys/refstr.h> 450Sstevel@tonic-gate #include <sys/avl.h> 460Sstevel@tonic-gate #include <sys/rctl.h> 470Sstevel@tonic-gate #include <sys/list.h> 480Sstevel@tonic-gate #include <sys/avl.h> 490Sstevel@tonic-gate #include <sys/door_impl.h> 500Sstevel@tonic-gate 510Sstevel@tonic-gate #ifdef __cplusplus 520Sstevel@tonic-gate extern "C" { 530Sstevel@tonic-gate #endif 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * Profile arguments. 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate struct prof { 590Sstevel@tonic-gate void *pr_base; /* buffer base */ 600Sstevel@tonic-gate uintptr_t pr_off; /* pc offset */ 610Sstevel@tonic-gate size_t pr_size; /* buffer size */ 620Sstevel@tonic-gate uint32_t pr_scale; /* pc scaling */ 630Sstevel@tonic-gate long pr_samples; /* sample count */ 640Sstevel@tonic-gate }; 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * An lwp directory entry. 680Sstevel@tonic-gate * If le_thread != NULL, this is an active lwp. 690Sstevel@tonic-gate * If le_thread == NULL, this is an unreaped zombie lwp. 700Sstevel@tonic-gate */ 710Sstevel@tonic-gate typedef struct lwpent { 720Sstevel@tonic-gate kthread_t *le_thread; /* the active lwp, NULL if zombie */ 730Sstevel@tonic-gate id_t le_lwpid; /* its lwpid (t->t_tid) */ 740Sstevel@tonic-gate uint16_t le_waiters; /* total number of lwp_wait()ers */ 750Sstevel@tonic-gate uint16_t le_dwaiters; /* number that are daemons */ 760Sstevel@tonic-gate clock_t le_start; /* start time of this lwp */ 770Sstevel@tonic-gate struct vnode *le_trace; /* pointer to /proc lwp vnode */ 780Sstevel@tonic-gate } lwpent_t; 790Sstevel@tonic-gate 801217Srab typedef struct pctxop { 811217Srab void (*save_op)(void *); /* function to invoke to save ctx */ 821217Srab void (*restore_op)(void *); /* function to invoke to restore ctx */ 831217Srab void (*fork_op)(void *, void *); /* invoke to fork context */ 841217Srab void (*exit_op)(void *); /* invoked during process exit */ 851217Srab void (*free_op)(void *, int); /* function which frees the context */ 861217Srab void *arg; /* argument to above functions */ 871217Srab struct pctxop *next; /* next pcontext ops */ 881217Srab } pctxop_t; 891217Srab 900Sstevel@tonic-gate /* 910Sstevel@tonic-gate * Elements of the lwp directory, p->p_lwpdir[]. 920Sstevel@tonic-gate * 930Sstevel@tonic-gate * We allocate lwp directory entries separately from lwp directory 940Sstevel@tonic-gate * elements because the lwp directory must be allocated as an array. 950Sstevel@tonic-gate * The number of lwps can grow quite large and we want to keep the 960Sstevel@tonic-gate * size of the kmem_alloc()d directory as small as possible. 970Sstevel@tonic-gate * 980Sstevel@tonic-gate * If ld_entry == NULL, the entry is free and is on the free list, 990Sstevel@tonic-gate * p->p_lwpfree, linked through ld_next. If ld_entry != NULL, the 1000Sstevel@tonic-gate * entry is used and ld_next is the thread-id hash link pointer. 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate typedef struct lwpdir { 1030Sstevel@tonic-gate struct lwpdir *ld_next; /* hash chain or free list */ 1040Sstevel@tonic-gate struct lwpent *ld_entry; /* lwp directory entry */ 1050Sstevel@tonic-gate } lwpdir_t; 1060Sstevel@tonic-gate 1079393SRoger.Faulkner@Sun.COM /* 1089393SRoger.Faulkner@Sun.COM * Element of the p_tidhash thread-id (lwpid) hash table. 1099393SRoger.Faulkner@Sun.COM */ 1109393SRoger.Faulkner@Sun.COM typedef struct tidhash { 1119393SRoger.Faulkner@Sun.COM kmutex_t th_lock; 1129393SRoger.Faulkner@Sun.COM lwpdir_t *th_list; 1139393SRoger.Faulkner@Sun.COM } tidhash_t; 1149393SRoger.Faulkner@Sun.COM 1159393SRoger.Faulkner@Sun.COM /* 1169393SRoger.Faulkner@Sun.COM * Retired tidhash hash tables. 1179393SRoger.Faulkner@Sun.COM */ 1189393SRoger.Faulkner@Sun.COM typedef struct ret_tidhash { 1199393SRoger.Faulkner@Sun.COM struct ret_tidhash *rth_next; 1209393SRoger.Faulkner@Sun.COM tidhash_t *rth_tidhash; 1219393SRoger.Faulkner@Sun.COM uint_t rth_tidhash_sz; 1229393SRoger.Faulkner@Sun.COM } ret_tidhash_t; 1239393SRoger.Faulkner@Sun.COM 1240Sstevel@tonic-gate struct pool; 1250Sstevel@tonic-gate struct task; 1260Sstevel@tonic-gate struct zone; 1272712Snn35248 struct brand; 1280Sstevel@tonic-gate struct corectl_path; 1290Sstevel@tonic-gate struct corectl_content; 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * One structure allocated per active process. It contains all 1330Sstevel@tonic-gate * data needed about the process while the process may be swapped 1340Sstevel@tonic-gate * out. Other per-process data (user.h) is also inside the proc structure. 1350Sstevel@tonic-gate * Lightweight-process data (lwp.h) and the kernel stack may be swapped out. 1360Sstevel@tonic-gate */ 1370Sstevel@tonic-gate typedef struct proc { 1380Sstevel@tonic-gate /* 1390Sstevel@tonic-gate * Fields requiring no explicit locking 1400Sstevel@tonic-gate */ 1410Sstevel@tonic-gate struct vnode *p_exec; /* pointer to a.out vnode */ 1420Sstevel@tonic-gate struct as *p_as; /* process address space pointer */ 1430Sstevel@tonic-gate struct plock *p_lockp; /* ptr to proc struct's mutex lock */ 1440Sstevel@tonic-gate kmutex_t p_crlock; /* lock for p_cred */ 1450Sstevel@tonic-gate struct cred *p_cred; /* process credentials */ 1460Sstevel@tonic-gate /* 1470Sstevel@tonic-gate * Fields protected by pidlock 1480Sstevel@tonic-gate */ 1490Sstevel@tonic-gate int p_swapcnt; /* number of swapped out lwps */ 1500Sstevel@tonic-gate char p_stat; /* status of process */ 1510Sstevel@tonic-gate char p_wcode; /* current wait code */ 1520Sstevel@tonic-gate ushort_t p_pidflag; /* flags protected only by pidlock */ 1530Sstevel@tonic-gate int p_wdata; /* current wait return value */ 1540Sstevel@tonic-gate pid_t p_ppid; /* process id of parent */ 1550Sstevel@tonic-gate struct proc *p_link; /* forward link */ 1560Sstevel@tonic-gate struct proc *p_parent; /* ptr to parent process */ 1570Sstevel@tonic-gate struct proc *p_child; /* ptr to first child process */ 1580Sstevel@tonic-gate struct proc *p_sibling; /* ptr to next sibling proc on chain */ 1590Sstevel@tonic-gate struct proc *p_psibling; /* ptr to prev sibling proc on chain */ 1600Sstevel@tonic-gate struct proc *p_sibling_ns; /* prt to siblings with new state */ 1610Sstevel@tonic-gate struct proc *p_child_ns; /* prt to children with new state */ 1620Sstevel@tonic-gate struct proc *p_next; /* active chain link next */ 1630Sstevel@tonic-gate struct proc *p_prev; /* active chain link prev */ 1640Sstevel@tonic-gate struct proc *p_nextofkin; /* gets accounting info at exit */ 1650Sstevel@tonic-gate struct proc *p_orphan; 1660Sstevel@tonic-gate struct proc *p_nextorph; 1670Sstevel@tonic-gate struct proc *p_pglink; /* process group hash chain link next */ 1680Sstevel@tonic-gate struct proc *p_ppglink; /* process group hash chain link prev */ 1690Sstevel@tonic-gate struct sess *p_sessp; /* session information */ 1700Sstevel@tonic-gate struct pid *p_pidp; /* process ID info */ 1710Sstevel@tonic-gate struct pid *p_pgidp; /* process group ID info */ 1720Sstevel@tonic-gate /* 1730Sstevel@tonic-gate * Fields protected by p_lock 1740Sstevel@tonic-gate */ 1750Sstevel@tonic-gate kcondvar_t p_cv; /* proc struct's condition variable */ 1760Sstevel@tonic-gate kcondvar_t p_flag_cv; 1770Sstevel@tonic-gate kcondvar_t p_lwpexit; /* waiting for some lwp to exit */ 1780Sstevel@tonic-gate kcondvar_t p_holdlwps; /* process is waiting for its lwps */ 1790Sstevel@tonic-gate /* to to be held. */ 1800Sstevel@tonic-gate uint_t p_proc_flag; /* /proc-related flags */ 1810Sstevel@tonic-gate uint_t p_flag; /* protected while set. */ 1820Sstevel@tonic-gate /* flags defined below */ 1830Sstevel@tonic-gate clock_t p_utime; /* user time, this process */ 1840Sstevel@tonic-gate clock_t p_stime; /* system time, this process */ 1850Sstevel@tonic-gate clock_t p_cutime; /* sum of children's user time */ 1860Sstevel@tonic-gate clock_t p_cstime; /* sum of children's system time */ 1870Sstevel@tonic-gate avl_tree_t *p_segacct; /* System V shared segment list */ 1880Sstevel@tonic-gate avl_tree_t *p_semacct; /* System V semaphore undo list */ 1890Sstevel@tonic-gate caddr_t p_bssbase; /* base addr of last bss below heap */ 1900Sstevel@tonic-gate caddr_t p_brkbase; /* base addr of heap */ 1910Sstevel@tonic-gate size_t p_brksize; /* heap size in bytes */ 1920Sstevel@tonic-gate uint_t p_brkpageszc; /* preferred heap max page size code */ 1930Sstevel@tonic-gate /* 1940Sstevel@tonic-gate * Per process signal stuff. 1950Sstevel@tonic-gate */ 1960Sstevel@tonic-gate k_sigset_t p_sig; /* signals pending to this process */ 1970Sstevel@tonic-gate k_sigset_t p_extsig; /* signals sent from another contract */ 1980Sstevel@tonic-gate k_sigset_t p_ignore; /* ignore when generated */ 1990Sstevel@tonic-gate k_sigset_t p_siginfo; /* gets signal info with signal */ 2000Sstevel@tonic-gate struct sigqueue *p_sigqueue; /* queued siginfo structures */ 2010Sstevel@tonic-gate struct sigqhdr *p_sigqhdr; /* hdr to sigqueue structure pool */ 2020Sstevel@tonic-gate struct sigqhdr *p_signhdr; /* hdr to signotify structure pool */ 2030Sstevel@tonic-gate uchar_t p_stopsig; /* jobcontrol stop signal */ 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate /* 2060Sstevel@tonic-gate * Special per-process flag when set will fix misaligned memory 2070Sstevel@tonic-gate * references. 2080Sstevel@tonic-gate */ 2090Sstevel@tonic-gate char p_fixalignment; 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate /* 2120Sstevel@tonic-gate * Per process lwp and kernel thread stuff 2130Sstevel@tonic-gate */ 2140Sstevel@tonic-gate id_t p_lwpid; /* most recently allocated lwpid */ 2150Sstevel@tonic-gate int p_lwpcnt; /* number of lwps in this process */ 2160Sstevel@tonic-gate int p_lwprcnt; /* number of not stopped lwps */ 2170Sstevel@tonic-gate int p_lwpdaemon; /* number of TP_DAEMON lwps */ 2180Sstevel@tonic-gate int p_lwpwait; /* number of lwps in lwp_wait() */ 2190Sstevel@tonic-gate int p_lwpdwait; /* number of daemons in lwp_wait() */ 2200Sstevel@tonic-gate int p_zombcnt; /* number of zombie lwps */ 2210Sstevel@tonic-gate kthread_t *p_tlist; /* circular list of threads */ 2220Sstevel@tonic-gate lwpdir_t *p_lwpdir; /* thread (lwp) directory */ 2230Sstevel@tonic-gate lwpdir_t *p_lwpfree; /* p_lwpdir free list */ 2249393SRoger.Faulkner@Sun.COM tidhash_t *p_tidhash; /* tid (lwpid) lookup hash table */ 2250Sstevel@tonic-gate uint_t p_lwpdir_sz; /* number of p_lwpdir[] entries */ 2260Sstevel@tonic-gate uint_t p_tidhash_sz; /* number of p_tidhash[] entries */ 2279393SRoger.Faulkner@Sun.COM ret_tidhash_t *p_ret_tidhash; /* retired tidhash hash tables */ 2280Sstevel@tonic-gate uint64_t p_lgrpset; /* unprotected hint of set of lgrps */ 2290Sstevel@tonic-gate /* on which process has threads */ 2304426Saguzovsk volatile lgrp_id_t p_t1_lgrpid; /* main's thread lgroup id */ 2314426Saguzovsk volatile lgrp_id_t p_tr_lgrpid; /* text replica's lgroup id */ 2324426Saguzovsk #if defined(_LP64) 2334426Saguzovsk uintptr_t p_lgrpres2; /* reserved for lgrp migration */ 2344426Saguzovsk #endif 2350Sstevel@tonic-gate /* 2360Sstevel@tonic-gate * /proc (process filesystem) debugger interface stuff. 2370Sstevel@tonic-gate */ 2380Sstevel@tonic-gate k_sigset_t p_sigmask; /* mask of traced signals (/proc) */ 2390Sstevel@tonic-gate k_fltset_t p_fltmask; /* mask of traced faults (/proc) */ 2400Sstevel@tonic-gate struct vnode *p_trace; /* pointer to primary /proc vnode */ 2410Sstevel@tonic-gate struct vnode *p_plist; /* list of /proc vnodes for process */ 2420Sstevel@tonic-gate kthread_t *p_agenttp; /* thread ptr for /proc agent lwp */ 2430Sstevel@tonic-gate avl_tree_t p_warea; /* list of watched areas */ 2440Sstevel@tonic-gate avl_tree_t p_wpage; /* remembered watched pages (vfork) */ 2450Sstevel@tonic-gate watched_page_t *p_wprot; /* pages that need to have prot set */ 2460Sstevel@tonic-gate int p_mapcnt; /* number of active pr_mappage()s */ 2470Sstevel@tonic-gate kmutex_t p_maplock; /* lock for pr_mappage() */ 2480Sstevel@tonic-gate struct proc *p_rlink; /* linked list for server */ 2490Sstevel@tonic-gate kcondvar_t p_srwchan_cv; 2500Sstevel@tonic-gate size_t p_stksize; /* process stack size in bytes */ 2510Sstevel@tonic-gate uint_t p_stkpageszc; /* preferred stack max page size code */ 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate /* 2540Sstevel@tonic-gate * Microstate accounting, resource usage, and real-time profiling 2550Sstevel@tonic-gate */ 2560Sstevel@tonic-gate hrtime_t p_mstart; /* hi-res process start time */ 2570Sstevel@tonic-gate hrtime_t p_mterm; /* hi-res process termination time */ 2580Sstevel@tonic-gate hrtime_t p_mlreal; /* elapsed time sum over defunct lwps */ 2590Sstevel@tonic-gate hrtime_t p_acct[NMSTATES]; /* microstate sum over defunct lwps */ 2600Sstevel@tonic-gate hrtime_t p_cacct[NMSTATES]; /* microstate sum over child procs */ 2610Sstevel@tonic-gate struct lrusage p_ru; /* lrusage sum over defunct lwps */ 2620Sstevel@tonic-gate struct lrusage p_cru; /* lrusage sum over child procs */ 2630Sstevel@tonic-gate struct itimerval p_rprof_timer; /* ITIMER_REALPROF interval timer */ 2640Sstevel@tonic-gate uintptr_t p_rprof_cyclic; /* ITIMER_REALPROF cyclic */ 2650Sstevel@tonic-gate uint_t p_defunct; /* number of defunct lwps */ 2660Sstevel@tonic-gate /* 2670Sstevel@tonic-gate * profiling. A lock is used in the event of multiple lwp's 2680Sstevel@tonic-gate * using the same profiling base/size. 2690Sstevel@tonic-gate */ 2700Sstevel@tonic-gate kmutex_t p_pflock; /* protects user profile arguments */ 2710Sstevel@tonic-gate struct prof p_prof; /* profile arguments */ 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate /* 2740Sstevel@tonic-gate * Doors. 2750Sstevel@tonic-gate */ 2760Sstevel@tonic-gate door_pool_t p_server_threads; /* common thread pool */ 2770Sstevel@tonic-gate struct door_node *p_door_list; /* active doors */ 2780Sstevel@tonic-gate struct door_node *p_unref_list; 2790Sstevel@tonic-gate kcondvar_t p_unref_cv; 2800Sstevel@tonic-gate char p_unref_thread; /* unref thread created */ 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate /* 2830Sstevel@tonic-gate * Kernel probes 2840Sstevel@tonic-gate */ 2850Sstevel@tonic-gate uchar_t p_tnf_flags; 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate /* 2885753Sgww * Solaris Audit 2890Sstevel@tonic-gate */ 2900Sstevel@tonic-gate struct p_audit_data *p_audit_data; /* per process audit structure */ 2911217Srab 2921217Srab pctxop_t *p_pctx; 2931217Srab 2940Sstevel@tonic-gate #if defined(__x86) 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * LDT support. 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate kmutex_t p_ldtlock; /* protects the following fields */ 2990Sstevel@tonic-gate user_desc_t *p_ldt; /* Pointer to private LDT */ 3000Sstevel@tonic-gate system_desc_t p_ldt_desc; /* segment descriptor for private LDT */ 3010Sstevel@tonic-gate ushort_t p_ldtlimit; /* highest selector used */ 3020Sstevel@tonic-gate #endif 3030Sstevel@tonic-gate size_t p_swrss; /* resident set size before last swap */ 3040Sstevel@tonic-gate struct aio *p_aio; /* pointer to async I/O struct */ 3050Sstevel@tonic-gate struct itimer **p_itimer; /* interval timers */ 3060Sstevel@tonic-gate timeout_id_t p_alarmid; /* alarm's timeout id */ 3070Sstevel@tonic-gate caddr_t p_usrstack; /* top of the process stack */ 3080Sstevel@tonic-gate uint_t p_stkprot; /* stack memory protection */ 3090Sstevel@tonic-gate uint_t p_datprot; /* data memory protection */ 3100Sstevel@tonic-gate model_t p_model; /* data model determined at exec time */ 3110Sstevel@tonic-gate struct lwpchan_data *p_lcp; /* lwpchan cache */ 3120Sstevel@tonic-gate kmutex_t p_lcp_lock; /* protects assignments to p_lcp */ 3130Sstevel@tonic-gate utrap_handler_t *p_utraps; /* pointer to user trap handlers */ 3140Sstevel@tonic-gate struct corectl_path *p_corefile; /* pattern for core file */ 3150Sstevel@tonic-gate struct task *p_task; /* our containing task */ 3160Sstevel@tonic-gate struct proc *p_taskprev; /* ptr to previous process in task */ 3170Sstevel@tonic-gate struct proc *p_tasknext; /* ptr to next process in task */ 3180Sstevel@tonic-gate kmutex_t p_sc_lock; /* protects p_pagep */ 3190Sstevel@tonic-gate struct sc_page_ctl *p_pagep; /* list of process's shared pages */ 3200Sstevel@tonic-gate struct rctl_set *p_rctls; /* resource controls for this process */ 3210Sstevel@tonic-gate rlim64_t p_stk_ctl; /* currently enforced stack size */ 3220Sstevel@tonic-gate rlim64_t p_fsz_ctl; /* currently enforced file size */ 3230Sstevel@tonic-gate rlim64_t p_vmem_ctl; /* currently enforced addr-space size */ 3240Sstevel@tonic-gate rlim64_t p_fno_ctl; /* currently enforced file-desc limit */ 3250Sstevel@tonic-gate pid_t p_ancpid; /* ancestor pid, used by exacct */ 3260Sstevel@tonic-gate struct itimerval p_realitimer; /* real interval timer */ 3270Sstevel@tonic-gate timeout_id_t p_itimerid; /* real interval timer's timeout id */ 3280Sstevel@tonic-gate struct corectl_content *p_content; /* content of core file */ 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate avl_tree_t p_ct_held; /* held contracts */ 3310Sstevel@tonic-gate struct ct_equeue **p_ct_equeue; /* process-type event queues */ 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate struct cont_process *p_ct_process; /* process contract */ 3340Sstevel@tonic-gate list_node_t p_ct_member; /* process contract membership */ 3350Sstevel@tonic-gate sigqueue_t *p_killsqp; /* sigqueue pointer for SIGKILL */ 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate int p_dtrace_probes; /* are there probes for this proc? */ 3380Sstevel@tonic-gate uint64_t p_dtrace_count; /* number of DTrace tracepoints */ 3390Sstevel@tonic-gate /* (protected by P_PR_LOCK) */ 3400Sstevel@tonic-gate void *p_dtrace_helpers; /* DTrace helpers, if any */ 3410Sstevel@tonic-gate struct pool *p_pool; /* pointer to containing pool */ 3420Sstevel@tonic-gate kcondvar_t p_poolcv; /* synchronization with pools */ 3430Sstevel@tonic-gate uint_t p_poolcnt; /* # threads inside pool barrier */ 3440Sstevel@tonic-gate uint_t p_poolflag; /* pool-related flags (see below) */ 3450Sstevel@tonic-gate uintptr_t p_portcnt; /* event ports counter */ 3460Sstevel@tonic-gate struct zone *p_zone; /* zone in which process lives */ 3470Sstevel@tonic-gate struct vnode *p_execdir; /* directory that p_exec came from */ 3482712Snn35248 struct brand *p_brand; /* process's brand */ 3492712Snn35248 void *p_brand_data; /* per-process brand state */ 3502712Snn35248 3512712Snn35248 /* additional lock to protect p_sessp (but not its contents) */ 3522712Snn35248 kmutex_t p_splock; 3532768Ssl108498 rctl_qty_t p_locked_mem; /* locked memory charged to proc */ 3542768Ssl108498 /* protected by p_lock */ 3553916Skrishna rctl_qty_t p_crypto_mem; /* /dev/crypto memory charged to proc */ 3563916Skrishna /* protected by p_lock */ 3575788Smv143129 clock_t p_ttime; /* buffered task time */ 35811913SRoger.Faulkner@Sun.COM 35911913SRoger.Faulkner@Sun.COM /* 36011913SRoger.Faulkner@Sun.COM * The user structure 36111913SRoger.Faulkner@Sun.COM */ 36211913SRoger.Faulkner@Sun.COM struct user p_user; /* (see sys/user.h) */ 3630Sstevel@tonic-gate } proc_t; 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate #define PROC_T /* headers relying on proc_t are OK */ 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate #ifdef _KERNEL 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate /* active process chain */ 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate extern proc_t *practive; 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate /* Well known processes */ 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate extern proc_t *proc_sched; /* memory scheduler */ 3760Sstevel@tonic-gate extern proc_t *proc_init; /* init */ 3770Sstevel@tonic-gate extern proc_t *proc_pageout; /* pageout daemon */ 3780Sstevel@tonic-gate extern proc_t *proc_fsflush; /* filesystem sync-er */ 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate #endif /* _KERNEL */ 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate /* 3830Sstevel@tonic-gate * Stuff to keep track of the number of processes each uid has. 3840Sstevel@tonic-gate * It is tracked on a per-zone basis; that is, if users in different 3850Sstevel@tonic-gate * zones have the same uid, they are tracked separately. 3860Sstevel@tonic-gate * 3870Sstevel@tonic-gate * A structure is allocated when a new <uid,zoneid> pair shows up 3880Sstevel@tonic-gate * There is a hash to find each structure. 3890Sstevel@tonic-gate */ 3900Sstevel@tonic-gate struct upcount { 3910Sstevel@tonic-gate struct upcount *up_next; 3920Sstevel@tonic-gate uid_t up_uid; 3930Sstevel@tonic-gate zoneid_t up_zoneid; 3940Sstevel@tonic-gate uint_t up_count; 3950Sstevel@tonic-gate }; 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate /* process ID info */ 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate struct pid { 4000Sstevel@tonic-gate unsigned int pid_prinactive :1; 4010Sstevel@tonic-gate unsigned int pid_pgorphaned :1; 4020Sstevel@tonic-gate unsigned int pid_padding :6; /* used to be pid_ref, now an int */ 4030Sstevel@tonic-gate unsigned int pid_prslot :24; 4040Sstevel@tonic-gate pid_t pid_id; 4050Sstevel@tonic-gate struct proc *pid_pglink; 406749Ssusans struct proc *pid_pgtail; 4070Sstevel@tonic-gate struct pid *pid_link; 4080Sstevel@tonic-gate uint_t pid_ref; 4090Sstevel@tonic-gate }; 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate #define p_pgrp p_pgidp->pid_id 4120Sstevel@tonic-gate #define p_pid p_pidp->pid_id 4130Sstevel@tonic-gate #define p_slot p_pidp->pid_prslot 4140Sstevel@tonic-gate #define p_detached p_pgidp->pid_pgorphaned 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate #define PID_HOLD(pidp) ASSERT(MUTEX_HELD(&pidlock)); \ 4170Sstevel@tonic-gate ++(pidp)->pid_ref; 4180Sstevel@tonic-gate #define PID_RELE(pidp) ASSERT(MUTEX_HELD(&pidlock)); \ 4190Sstevel@tonic-gate (pidp)->pid_ref > 1 ? \ 4200Sstevel@tonic-gate --(pidp)->pid_ref : pid_rele(pidp); 4210Sstevel@tonic-gate 4220Sstevel@tonic-gate /* 4230Sstevel@tonic-gate * Structure containing persistent process lock. The structure and 4240Sstevel@tonic-gate * macro allow "mutex_enter(&p->p_lock)" to continue working. 4250Sstevel@tonic-gate */ 4260Sstevel@tonic-gate struct plock { 4270Sstevel@tonic-gate kmutex_t pl_lock; 4280Sstevel@tonic-gate }; 4290Sstevel@tonic-gate #define p_lock p_lockp->pl_lock 4300Sstevel@tonic-gate 4310Sstevel@tonic-gate #ifdef _KERNEL 4320Sstevel@tonic-gate extern proc_t p0; /* process 0 */ 4330Sstevel@tonic-gate extern struct plock p0lock; /* p0's plock */ 4340Sstevel@tonic-gate extern struct pid pid0; /* p0's pid */ 4352712Snn35248 4362712Snn35248 /* pid_allocate() flags */ 4372712Snn35248 #define PID_ALLOC_PROC 0x0001 /* assign a /proc slot as well */ 4382712Snn35248 4390Sstevel@tonic-gate #endif /* _KERNEL */ 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate /* stat codes */ 4420Sstevel@tonic-gate 4430Sstevel@tonic-gate #define SSLEEP 1 /* awaiting an event */ 4443792Sakolb #define SRUN 2 /* runnable */ 4450Sstevel@tonic-gate #define SZOMB 3 /* process terminated but not waited for */ 4460Sstevel@tonic-gate #define SSTOP 4 /* process stopped by debugger */ 4470Sstevel@tonic-gate #define SIDL 5 /* intermediate state in process creation */ 4480Sstevel@tonic-gate #define SONPROC 6 /* process is being run on a processor */ 4493792Sakolb #define SWAIT 7 /* process is waiting to become runnable */ 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate /* p_pidflag codes */ 4523235Sraf #define CLDPEND 0x0001 /* have yet to post a SIGCHLD to the parent */ 4533235Sraf #define CLDCONT 0x0002 /* child has notified parent of CLD_CONTINUED */ 4543235Sraf #define CLDNOSIGCHLD 0x0004 /* do not post SIGCHLD when child terminates */ 4553235Sraf #define CLDWAITPID 0x0008 /* only waitid(P_PID, pid) can reap the child */ 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate /* p_proc_flag codes -- these flags are mostly private to /proc */ 4580Sstevel@tonic-gate #define P_PR_TRACE 0x0001 /* signal, fault or syscall tracing via /proc */ 4590Sstevel@tonic-gate #define P_PR_PTRACE 0x0002 /* ptrace() compatibility mode */ 4600Sstevel@tonic-gate #define P_PR_FORK 0x0004 /* child inherits tracing flags */ 4610Sstevel@tonic-gate #define P_PR_LOCK 0x0008 /* process locked by /proc */ 4620Sstevel@tonic-gate #define P_PR_ASYNC 0x0010 /* asynchronous stopping via /proc */ 4630Sstevel@tonic-gate #define P_PR_EXEC 0x0020 /* process is in exec() */ 4640Sstevel@tonic-gate #define P_PR_BPTADJ 0x0040 /* adjust pc on breakpoint trap */ 4650Sstevel@tonic-gate #define P_PR_RUNLCL 0x0080 /* set process running on last /proc close */ 4660Sstevel@tonic-gate #define P_PR_KILLCL 0x0100 /* kill process on last /proc close */ 4670Sstevel@tonic-gate 4680Sstevel@tonic-gate /* 4690Sstevel@tonic-gate * p_flag codes 4700Sstevel@tonic-gate * 4710Sstevel@tonic-gate * note that two of these flags, SMSACCT and SSYS, are exported to /proc's 4720Sstevel@tonic-gate * psinfo_t.p_flag field. Historically, all were, but since they are 4730Sstevel@tonic-gate * implementation dependant, we only export the ones people have come to 4740Sstevel@tonic-gate * rely upon. Hence, the bit positions of SSYS and SMSACCT should not be 4750Sstevel@tonic-gate * altered. 4760Sstevel@tonic-gate */ 4770Sstevel@tonic-gate #define SSYS 0x00000001 /* system (resident) process */ 478390Sraf #define SEXITING 0x00000002 /* process is exiting */ 4790Sstevel@tonic-gate #define SITBUSY 0x00000004 /* setitimer(ITIMER_REAL) in progress */ 4801880Sahl #define SFORKING 0x00000008 /* tells called functions that we're forking */ 4810Sstevel@tonic-gate #define SWATCHOK 0x00000010 /* proc in acceptable state for watchpoints */ 4820Sstevel@tonic-gate #define SKILLED 0x00000100 /* SIGKILL has been posted to the process */ 4830Sstevel@tonic-gate #define SSCONT 0x00000200 /* SIGCONT has been posted to the process */ 4840Sstevel@tonic-gate #define SZONETOP 0x00000400 /* process has no valid PPID in its zone */ 4850Sstevel@tonic-gate #define SEXTKILLED 0x00000800 /* SKILLED is from another contract */ 4860Sstevel@tonic-gate #define SUGID 0x00002000 /* process was result of set[ug]id exec */ 4870Sstevel@tonic-gate #define SEXECED 0x00004000 /* this process has execed */ 4883235Sraf #define SJCTL 0x00010000 /* SIGCHLD sent when children stop/continue */ 4890Sstevel@tonic-gate #define SNOWAIT 0x00020000 /* children never become zombies */ 4900Sstevel@tonic-gate #define SVFORK 0x00040000 /* child of vfork that has not yet exec'd */ 4910Sstevel@tonic-gate #define SVFWAIT 0x00080000 /* parent of vfork waiting for child to exec */ 4920Sstevel@tonic-gate #define SEXITLWPS 0x00100000 /* have lwps exit within the process */ 4930Sstevel@tonic-gate #define SHOLDFORK 0x00200000 /* hold lwps where they're cloneable */ 4940Sstevel@tonic-gate #define SHOLDFORK1 0x00800000 /* hold lwps in place (not cloning) */ 4950Sstevel@tonic-gate #define SCOREDUMP 0x01000000 /* process is dumping core */ 4960Sstevel@tonic-gate #define SMSACCT 0x02000000 /* process is keeping micro-state accounting */ 4970Sstevel@tonic-gate #define SLWPWRAP 0x04000000 /* process has wrapped its lwp ids */ 4980Sstevel@tonic-gate #define SAUTOLPG 0x08000000 /* kernel controls page sizes */ 4990Sstevel@tonic-gate #define SNOCD 0x10000000 /* new creds from VSxID, do not coredump */ 5000Sstevel@tonic-gate #define SHOLDWATCH 0x20000000 /* hold lwps for watchpoint operation */ 5010Sstevel@tonic-gate #define SMSFORK 0x40000000 /* child inherits micro-state accounting */ 5020Sstevel@tonic-gate #define SDOCORE 0x80000000 /* process will attempt to dump core */ 5030Sstevel@tonic-gate 5040Sstevel@tonic-gate /* 5050Sstevel@tonic-gate * p_poolflag codes 5060Sstevel@tonic-gate * 5070Sstevel@tonic-gate * These flags are used to synchronize with the pool subsystem to allow 5080Sstevel@tonic-gate * re-binding of processes to new pools. 5090Sstevel@tonic-gate */ 5102768Ssl108498 #define PBWAIT 0x0001 /* process should wait outside fork/exec/exit */ 5112768Ssl108498 #define PEXITED 0x0002 /* process exited and about to become zombie */ 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate /* Macro to convert proc pointer to a user block pointer */ 5140Sstevel@tonic-gate #define PTOU(p) (&(p)->p_user) 5150Sstevel@tonic-gate 5160Sstevel@tonic-gate #define tracing(p, sig) (sigismember(&(p)->p_sigmask, sig)) 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate /* Macro to reduce unnecessary calls to issig() */ 5190Sstevel@tonic-gate 5200Sstevel@tonic-gate #define ISSIG(t, why) ISSIG_FAST(t, ttolwp(t), ttoproc(t), why) 5210Sstevel@tonic-gate 5220Sstevel@tonic-gate /* 5230Sstevel@tonic-gate * Fast version of ISSIG. 5240Sstevel@tonic-gate * 1. uses register pointers to lwp and proc instead of reloading them. 5250Sstevel@tonic-gate * 2. uses bit-wise OR of tests, since the usual case is that none of them 5260Sstevel@tonic-gate * are true, this saves orcc's and branches. 5270Sstevel@tonic-gate * 3. load the signal flags instead of using sigisempty() macro which does 5280Sstevel@tonic-gate * a branch to convert to boolean. 5290Sstevel@tonic-gate */ 5300Sstevel@tonic-gate #define ISSIG_FAST(t, lwp, p, why) \ 5310Sstevel@tonic-gate (ISSIG_PENDING(t, lwp, p) && issig(why)) 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate #define ISSIG_PENDING(t, lwp, p) \ 5340Sstevel@tonic-gate ((lwp)->lwp_cursig | \ 5350Sstevel@tonic-gate sigcheck((p), (t)) | \ 5360Sstevel@tonic-gate (p)->p_stopsig | \ 5370Sstevel@tonic-gate (t)->t_dtrace_stop | \ 5380Sstevel@tonic-gate (t)->t_dtrace_sig | \ 5390Sstevel@tonic-gate ((t)->t_proc_flag & (TP_PRSTOP|TP_HOLDLWP|TP_CHKPT|TP_PAUSE)) | \ 5400Sstevel@tonic-gate ((p)->p_flag & (SEXITLWPS|SKILLED|SHOLDFORK1|SHOLDWATCH))) 5410Sstevel@tonic-gate 5420Sstevel@tonic-gate #define ISSTOP(sig) (u.u_signal[sig-1] == SIG_DFL && \ 5430Sstevel@tonic-gate sigismember(&stopdefault, sig)) 5440Sstevel@tonic-gate 5450Sstevel@tonic-gate #define ISHOLD(p) ((p)->p_flag & SHOLDFORK) 5460Sstevel@tonic-gate 5470Sstevel@tonic-gate #define MUSTRETURN(p, t) (ISHOLD(p) | (t)->t_activefd.a_stale) 5480Sstevel@tonic-gate 5490Sstevel@tonic-gate /* 5500Sstevel@tonic-gate * Determine if there are any watchpoints active in the process. 5510Sstevel@tonic-gate */ 5520Sstevel@tonic-gate #define pr_watch_active(p) (avl_numnodes(&(p)->p_warea) != 0) 5530Sstevel@tonic-gate 5540Sstevel@tonic-gate /* Reasons for calling issig() */ 5550Sstevel@tonic-gate 5560Sstevel@tonic-gate #define FORREAL 0 /* Usual side-effects */ 5570Sstevel@tonic-gate #define JUSTLOOKING 1 /* Don't stop the process */ 5580Sstevel@tonic-gate 5590Sstevel@tonic-gate /* 'what' values for stop(PR_SUSPENDED, what) */ 5600Sstevel@tonic-gate #define SUSPEND_NORMAL 0 5610Sstevel@tonic-gate #define SUSPEND_PAUSE 1 5620Sstevel@tonic-gate 5630Sstevel@tonic-gate /* pseudo-flag to lwp_create() */ 5640Sstevel@tonic-gate #define NOCLASS (-1) 5650Sstevel@tonic-gate 56611173SJonathan.Adams@Sun.COM /* unused scheduling class ID */ 56711173SJonathan.Adams@Sun.COM #define CLASS_UNUSED (-2) 56811173SJonathan.Adams@Sun.COM 5690Sstevel@tonic-gate /* LWP stats updated via lwp_stats_update() */ 5700Sstevel@tonic-gate typedef enum { 5710Sstevel@tonic-gate LWP_STAT_INBLK, 5720Sstevel@tonic-gate LWP_STAT_OUBLK, 5730Sstevel@tonic-gate LWP_STAT_MSGRCV, 5740Sstevel@tonic-gate LWP_STAT_MSGSND 5750Sstevel@tonic-gate } lwp_stat_id_t; 5760Sstevel@tonic-gate 5770Sstevel@tonic-gate #ifdef _KERNEL 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate /* user profiling functions */ 5800Sstevel@tonic-gate 5810Sstevel@tonic-gate extern void profil_tick(uintptr_t); 5820Sstevel@tonic-gate 5830Sstevel@tonic-gate /* process management functions */ 5840Sstevel@tonic-gate 58511173SJonathan.Adams@Sun.COM extern int newproc(void (*)(), caddr_t, id_t, int, struct contract **, pid_t); 5860Sstevel@tonic-gate extern void vfwait(pid_t); 5870Sstevel@tonic-gate extern void proc_detach(proc_t *); 5880Sstevel@tonic-gate extern void freeproc(proc_t *); 5890Sstevel@tonic-gate extern void setrun(kthread_t *); 5900Sstevel@tonic-gate extern void setrun_locked(kthread_t *); 5910Sstevel@tonic-gate extern void exit(int, int); 5920Sstevel@tonic-gate extern int proc_exit(int, int); 593390Sraf extern void proc_is_exiting(proc_t *); 5940Sstevel@tonic-gate extern void relvm(void); 5950Sstevel@tonic-gate extern void add_ns(proc_t *, proc_t *); 5960Sstevel@tonic-gate extern void delete_ns(proc_t *, proc_t *); 5970Sstevel@tonic-gate extern void upcount_inc(uid_t, zoneid_t); 5980Sstevel@tonic-gate extern void upcount_dec(uid_t, zoneid_t); 5990Sstevel@tonic-gate extern int upcount_get(uid_t, zoneid_t); 6000Sstevel@tonic-gate #if defined(__x86) 6010Sstevel@tonic-gate extern selector_t setup_thrptr(proc_t *, uintptr_t); 6022086Ssudheer extern void deferred_singlestep_trap(caddr_t); 6030Sstevel@tonic-gate #endif 6040Sstevel@tonic-gate 6050Sstevel@tonic-gate extern void sigcld(proc_t *, sigqueue_t *); 6060Sstevel@tonic-gate extern void sigcld_delete(k_siginfo_t *); 6070Sstevel@tonic-gate extern void sigcld_repost(void); 6080Sstevel@tonic-gate extern int fsig(k_sigset_t *, kthread_t *); 6090Sstevel@tonic-gate extern void psig(void); 6100Sstevel@tonic-gate extern void stop(int, int); 6110Sstevel@tonic-gate extern int stop_on_fault(uint_t, k_siginfo_t *); 6120Sstevel@tonic-gate extern int issig(int); 6130Sstevel@tonic-gate extern int jobstopped(proc_t *); 6140Sstevel@tonic-gate extern void psignal(proc_t *, int); 6150Sstevel@tonic-gate extern void tsignal(kthread_t *, int); 6160Sstevel@tonic-gate extern void sigtoproc(proc_t *, kthread_t *, int); 6170Sstevel@tonic-gate extern void trapsig(k_siginfo_t *, int); 6189870SRoger.Faulkner@Sun.COM extern void realsigprof(int, int, int); 6190Sstevel@tonic-gate extern int eat_signal(kthread_t *, int); 6200Sstevel@tonic-gate extern int signal_is_blocked(kthread_t *, int); 6210Sstevel@tonic-gate extern int sigcheck(proc_t *, kthread_t *); 6220Sstevel@tonic-gate extern void sigdefault(proc_t *); 6230Sstevel@tonic-gate 6240Sstevel@tonic-gate extern void pid_setmin(void); 62511173SJonathan.Adams@Sun.COM extern pid_t pid_allocate(proc_t *, pid_t, int); 6260Sstevel@tonic-gate extern int pid_rele(struct pid *); 627*12834SMenno.Lageman@Sun.COM extern void pid_exit(proc_t *, struct task *); 6280Sstevel@tonic-gate extern void proc_entry_free(struct pid *); 6290Sstevel@tonic-gate extern proc_t *prfind(pid_t); 6300Sstevel@tonic-gate extern proc_t *prfind_zone(pid_t, zoneid_t); 6310Sstevel@tonic-gate extern proc_t *pgfind(pid_t); 6320Sstevel@tonic-gate extern proc_t *pgfind_zone(pid_t, zoneid_t); 6330Sstevel@tonic-gate extern proc_t *sprlock(pid_t); 6340Sstevel@tonic-gate extern proc_t *sprlock_zone(pid_t, zoneid_t); 6353247Sgjelinek extern int sprtrylock_proc(proc_t *); 6363247Sgjelinek extern void sprwaitlock_proc(proc_t *); 6370Sstevel@tonic-gate extern void sprlock_proc(proc_t *); 6380Sstevel@tonic-gate extern void sprunlock(proc_t *); 6390Sstevel@tonic-gate extern void pid_init(void); 6400Sstevel@tonic-gate extern proc_t *pid_entry(int); 6410Sstevel@tonic-gate extern int pid_slot(proc_t *); 6420Sstevel@tonic-gate extern void signal(pid_t, int); 6430Sstevel@tonic-gate extern void prsignal(struct pid *, int); 6440Sstevel@tonic-gate extern int uread(proc_t *, void *, size_t, uintptr_t); 6450Sstevel@tonic-gate extern int uwrite(proc_t *, void *, size_t, uintptr_t); 6460Sstevel@tonic-gate 6470Sstevel@tonic-gate extern void pgsignal(struct pid *, int); 6480Sstevel@tonic-gate extern void pgjoin(proc_t *, struct pid *); 6490Sstevel@tonic-gate extern void pgcreate(proc_t *); 6500Sstevel@tonic-gate extern void pgexit(proc_t *); 6510Sstevel@tonic-gate extern void pgdetach(proc_t *); 6520Sstevel@tonic-gate extern int pgmembers(pid_t); 6530Sstevel@tonic-gate 6540Sstevel@tonic-gate extern void init_mstate(kthread_t *, int); 6550Sstevel@tonic-gate extern int new_mstate(kthread_t *, int); 6560Sstevel@tonic-gate extern void restore_mstate(kthread_t *); 6570Sstevel@tonic-gate extern void term_mstate(kthread_t *); 6580Sstevel@tonic-gate extern void estimate_msacct(kthread_t *, hrtime_t); 6590Sstevel@tonic-gate extern void disable_msacct(proc_t *); 6600Sstevel@tonic-gate extern hrtime_t mstate_aggr_state(proc_t *, int); 6613792Sakolb extern hrtime_t mstate_thread_onproc_time(kthread_t *); 66211173SJonathan.Adams@Sun.COM extern void mstate_systhread_times(kthread_t *, hrtime_t *, hrtime_t *); 6630Sstevel@tonic-gate extern void syscall_mstate(int, int); 6640Sstevel@tonic-gate 6650Sstevel@tonic-gate extern uint_t cpu_update_pct(kthread_t *, hrtime_t); 6660Sstevel@tonic-gate 6670Sstevel@tonic-gate extern void set_proc_pre_sys(proc_t *p); 6680Sstevel@tonic-gate extern void set_proc_post_sys(proc_t *p); 6690Sstevel@tonic-gate extern void set_proc_sys(proc_t *p); 6700Sstevel@tonic-gate extern void set_proc_ast(proc_t *p); 6710Sstevel@tonic-gate extern void set_all_proc_sys(void); 67211861SMarek.Pospisil@Sun.COM extern void set_all_zone_usr_proc_sys(zoneid_t); 6730Sstevel@tonic-gate 6740Sstevel@tonic-gate /* thread function prototypes */ 6750Sstevel@tonic-gate 6760Sstevel@tonic-gate extern kthread_t *thread_create( 6770Sstevel@tonic-gate caddr_t stk, 6780Sstevel@tonic-gate size_t stksize, 6790Sstevel@tonic-gate void (*proc)(), 6800Sstevel@tonic-gate void *arg, 6810Sstevel@tonic-gate size_t len, 6820Sstevel@tonic-gate proc_t *pp, 6830Sstevel@tonic-gate int state, 6840Sstevel@tonic-gate pri_t pri); 6850Sstevel@tonic-gate extern void thread_exit(void) __NORETURN; 6860Sstevel@tonic-gate extern void thread_free(kthread_t *); 6870Sstevel@tonic-gate extern void thread_rele(kthread_t *); 6880Sstevel@tonic-gate extern void thread_join(kt_did_t); 6890Sstevel@tonic-gate extern int reaper(void); 6900Sstevel@tonic-gate extern void installctx(kthread_t *, void *, void (*)(), void (*)(), 6910Sstevel@tonic-gate void (*)(), void (*)(), void (*)(), void (*)()); 6920Sstevel@tonic-gate extern int removectx(kthread_t *, void *, void (*)(), void (*)(), 6930Sstevel@tonic-gate void (*)(), void (*)(), void (*)(), void (*)()); 6940Sstevel@tonic-gate extern void savectx(kthread_t *); 6950Sstevel@tonic-gate extern void restorectx(kthread_t *); 6960Sstevel@tonic-gate extern void forkctx(kthread_t *, kthread_t *); 6970Sstevel@tonic-gate extern void lwp_createctx(kthread_t *, kthread_t *); 6980Sstevel@tonic-gate extern void exitctx(kthread_t *); 6990Sstevel@tonic-gate extern void freectx(kthread_t *, int); 7001217Srab extern void installpctx(proc_t *, void *, void (*)(), void (*)(), 7011217Srab void (*)(), void (*)(), void (*)()); 7021217Srab extern int removepctx(proc_t *, void *, void (*)(), void (*)(), 7031217Srab void (*)(), void (*)(), void (*)()); 7041217Srab extern void savepctx(proc_t *); 7051217Srab extern void restorepctx(proc_t *); 7061217Srab extern void forkpctx(proc_t *, proc_t *); 7071217Srab extern void exitpctx(proc_t *); 7081217Srab extern void freepctx(proc_t *, int); 7090Sstevel@tonic-gate extern kthread_t *thread_unpin(void); 7100Sstevel@tonic-gate extern void thread_init(void); 7110Sstevel@tonic-gate extern void thread_load(kthread_t *, void (*)(), caddr_t, size_t); 7120Sstevel@tonic-gate 7130Sstevel@tonic-gate extern void tsd_create(uint_t *, void (*)(void *)); 7140Sstevel@tonic-gate extern void tsd_destroy(uint_t *); 7150Sstevel@tonic-gate extern void *tsd_getcreate(uint_t *, void (*)(void *), void *(*)(void)); 7160Sstevel@tonic-gate extern void *tsd_get(uint_t); 7170Sstevel@tonic-gate extern int tsd_set(uint_t, void *); 7180Sstevel@tonic-gate extern void tsd_exit(void); 7190Sstevel@tonic-gate extern void *tsd_agent_get(kthread_t *, uint_t); 7200Sstevel@tonic-gate extern int tsd_agent_set(kthread_t *, uint_t, void *); 7210Sstevel@tonic-gate 7220Sstevel@tonic-gate /* lwp function prototypes */ 7230Sstevel@tonic-gate 72411173SJonathan.Adams@Sun.COM extern kthread_t *lwp_kernel_create(proc_t *, void (*)(), void *, int, pri_t); 7250Sstevel@tonic-gate extern klwp_t *lwp_create( 7260Sstevel@tonic-gate void (*proc)(), 7270Sstevel@tonic-gate caddr_t arg, 7280Sstevel@tonic-gate size_t len, 7290Sstevel@tonic-gate proc_t *p, 7300Sstevel@tonic-gate int state, 7310Sstevel@tonic-gate int pri, 7320Sstevel@tonic-gate const k_sigset_t *smask, 7330Sstevel@tonic-gate int cid, 7340Sstevel@tonic-gate id_t lwpid); 7350Sstevel@tonic-gate extern kthread_t *idtot(proc_t *, id_t); 7369393SRoger.Faulkner@Sun.COM extern void lwp_hash_in(proc_t *, lwpent_t *, tidhash_t *, uint_t, int); 7370Sstevel@tonic-gate extern void lwp_hash_out(proc_t *, id_t); 7380Sstevel@tonic-gate extern lwpdir_t *lwp_hash_lookup(proc_t *, id_t); 7399393SRoger.Faulkner@Sun.COM extern lwpdir_t *lwp_hash_lookup_and_lock(proc_t *, id_t, kmutex_t **); 7400Sstevel@tonic-gate extern void lwp_create_done(kthread_t *); 7410Sstevel@tonic-gate extern void lwp_exit(void); 7420Sstevel@tonic-gate extern void lwp_pcb_exit(void); 7430Sstevel@tonic-gate extern void lwp_cleanup(void); 7440Sstevel@tonic-gate extern int lwp_suspend(kthread_t *); 7450Sstevel@tonic-gate extern void lwp_continue(kthread_t *); 7460Sstevel@tonic-gate extern void holdlwp(void); 7470Sstevel@tonic-gate extern void stoplwp(void); 7480Sstevel@tonic-gate extern int holdlwps(int); 7490Sstevel@tonic-gate extern int holdwatch(void); 7500Sstevel@tonic-gate extern void pokelwps(proc_t *); 7510Sstevel@tonic-gate extern void continuelwps(proc_t *); 7520Sstevel@tonic-gate extern int exitlwps(int); 7530Sstevel@tonic-gate extern void lwp_ctmpl_copy(klwp_t *, klwp_t *); 7540Sstevel@tonic-gate extern void lwp_ctmpl_clear(klwp_t *); 7550Sstevel@tonic-gate extern klwp_t *forklwp(klwp_t *, proc_t *, id_t); 7560Sstevel@tonic-gate extern void lwp_load(klwp_t *, gregset_t, uintptr_t); 7570Sstevel@tonic-gate extern void lwp_setrval(klwp_t *, int, int); 7580Sstevel@tonic-gate extern void lwp_forkregs(klwp_t *, klwp_t *); 7590Sstevel@tonic-gate extern void lwp_freeregs(klwp_t *, int); 7600Sstevel@tonic-gate extern caddr_t lwp_stk_init(klwp_t *, caddr_t); 7612005Selowe extern void lwp_stk_cache_init(void); 7620Sstevel@tonic-gate extern void lwp_stk_fini(klwp_t *); 7630Sstevel@tonic-gate extern void lwp_installctx(klwp_t *); 7640Sstevel@tonic-gate extern void lwp_rtt(void); 7650Sstevel@tonic-gate extern void lwp_rtt_initial(void); 7660Sstevel@tonic-gate extern int lwp_setprivate(klwp_t *, int, uintptr_t); 7670Sstevel@tonic-gate extern void lwp_stat_update(lwp_stat_id_t, long); 7682712Snn35248 extern void lwp_attach_brand_hdlrs(klwp_t *); 7696994Sedp extern void lwp_detach_brand_hdlrs(klwp_t *); 7700Sstevel@tonic-gate 7719351SPrashanth.Sreenivasa@Sun.COM #if defined(__sparcv9) 7729351SPrashanth.Sreenivasa@Sun.COM extern void lwp_mmodel_newlwp(void); 7739351SPrashanth.Sreenivasa@Sun.COM extern void lwp_mmodel_shared_as(caddr_t, size_t); 7749351SPrashanth.Sreenivasa@Sun.COM #define LWP_MMODEL_NEWLWP() lwp_mmodel_newlwp() 7759351SPrashanth.Sreenivasa@Sun.COM #define LWP_MMODEL_SHARED_AS(addr, sz) lwp_mmodel_shared_as((addr), (sz)) 7769351SPrashanth.Sreenivasa@Sun.COM #else 7779351SPrashanth.Sreenivasa@Sun.COM #define LWP_MMODEL_NEWLWP() 7789351SPrashanth.Sreenivasa@Sun.COM #define LWP_MMODEL_SHARED_AS(addr, sz) 7799351SPrashanth.Sreenivasa@Sun.COM #endif 7809351SPrashanth.Sreenivasa@Sun.COM 7810Sstevel@tonic-gate /* 7820Sstevel@tonic-gate * Signal queue function prototypes. Must be here due to header ordering 7830Sstevel@tonic-gate * dependencies. 7840Sstevel@tonic-gate */ 7850Sstevel@tonic-gate extern void sigqfree(proc_t *); 7860Sstevel@tonic-gate extern void siginfofree(sigqueue_t *); 7870Sstevel@tonic-gate extern void sigdeq(proc_t *, kthread_t *, int, sigqueue_t **); 7880Sstevel@tonic-gate extern void sigdelq(proc_t *, kthread_t *, int); 7890Sstevel@tonic-gate extern void sigaddq(proc_t *, kthread_t *, k_siginfo_t *, int); 7900Sstevel@tonic-gate extern void sigaddqa(proc_t *, kthread_t *, sigqueue_t *); 7910Sstevel@tonic-gate extern void sigqsend(int, proc_t *, kthread_t *, sigqueue_t *); 7920Sstevel@tonic-gate extern void sigdupq(proc_t *, proc_t *); 7930Sstevel@tonic-gate extern int sigwillqueue(int, int); 7940Sstevel@tonic-gate extern sigqhdr_t *sigqhdralloc(size_t, uint_t); 7950Sstevel@tonic-gate extern sigqueue_t *sigqalloc(sigqhdr_t *); 7960Sstevel@tonic-gate extern void sigqhdrfree(sigqhdr_t *); 7970Sstevel@tonic-gate extern sigqueue_t *sigappend(k_sigset_t *, sigqueue_t *, 7980Sstevel@tonic-gate k_sigset_t *, sigqueue_t *); 7990Sstevel@tonic-gate extern sigqueue_t *sigprepend(k_sigset_t *, sigqueue_t *, 8000Sstevel@tonic-gate k_sigset_t *, sigqueue_t *); 8010Sstevel@tonic-gate extern void winfo(proc_t *, k_siginfo_t *, int); 8020Sstevel@tonic-gate extern int wstat(int, int); 8030Sstevel@tonic-gate extern int sendsig(int, k_siginfo_t *, void (*)()); 8040Sstevel@tonic-gate #if defined(_SYSCALL32_IMPL) 8050Sstevel@tonic-gate extern int sendsig32(int, k_siginfo_t *, void (*)()); 8060Sstevel@tonic-gate #endif 8070Sstevel@tonic-gate 8080Sstevel@tonic-gate #endif /* _KERNEL */ 8090Sstevel@tonic-gate 8100Sstevel@tonic-gate #ifdef __cplusplus 8110Sstevel@tonic-gate } 8120Sstevel@tonic-gate #endif 8130Sstevel@tonic-gate 8140Sstevel@tonic-gate #endif /* _SYS_PROC_H */ 815