1 /* proc.h 4.22 83/05/22 */ 2 3 /* 4 * One structure allocated per active 5 * process. It contains all data needed 6 * about the process while the 7 * process may be swapped out. 8 * Other per process data (user.h) 9 * is swapped with the process. 10 */ 11 struct proc { 12 struct proc *p_link; /* linked list of running processes */ 13 struct proc *p_rlink; 14 struct pte *p_addr; /* u-area kernel map address */ 15 char p_usrpri; /* user-priority based on p_cpu and p_nice */ 16 char p_pri; /* priority, negative is high */ 17 char p_cpu; /* cpu usage for scheduling */ 18 char p_stat; 19 char p_time; /* resident time for scheduling */ 20 char p_nice; /* nice for cpu usage */ 21 char p_slptime; /* time since last block */ 22 char p_cursig; 23 long p_sig; /* signals pending to this process */ 24 long p_siga0; /* low bit of 2 bit signal action */ 25 long p_siga1; /* high bit of 2 bit signal action */ 26 #define p_ignsig p_siga0 /* ignored signal mask */ 27 int p_flag; 28 short p_uid; /* user id, used to direct tty signals */ 29 short p_pgrp; /* name of process group leader */ 30 short p_pid; /* unique process id */ 31 short p_ppid; /* process id of parent */ 32 u_short p_xstat; /* Exit status for wait */ 33 struct rusage *p_ru; /* mbuf holding exit information */ 34 short p_poip; /* page outs in progress */ 35 short p_szpt; /* copy of page table size */ 36 size_t p_tsize; /* size of text (clicks) */ 37 size_t p_dsize; /* size of data space (clicks) */ 38 size_t p_ssize; /* copy of stack size (clicks) */ 39 size_t p_rssize; /* current resident set size in clicks */ 40 size_t p_maxrss; /* copy of u.u_limit[MAXRSS] */ 41 size_t p_swrss; /* resident set size before last swap */ 42 swblk_t p_swaddr; /* disk address of u area when swapped */ 43 caddr_t p_wchan; /* event process is awaiting */ 44 struct text *p_textp; /* pointer to text structure */ 45 struct pte *p_p0br; /* page table base P0BR */ 46 struct proc *p_xlink; /* linked list of procs sharing same text */ 47 short p_cpticks; /* ticks of cpu time */ 48 float p_pctcpu; /* %cpu for this process during p_time */ 49 short p_ndx; /* proc index for memall (because of vfork) */ 50 short p_idhash; /* hashed based on p_pid for kill+exit+... */ 51 struct proc *p_pptr; /* pointer to process structure of parent */ 52 struct proc *p_cptr; /* pointer to youngest living child */ 53 struct proc *p_osptr; /* pointer to older sibling processes */ 54 struct proc *p_ysptr; /* pointer to younger siblings */ 55 struct itimerval p_realtimer; 56 struct quota *p_quota; /* quotas for this process */ 57 #ifdef sun 58 struct context *p_ctx; /* pointer to current context */ 59 #endif 60 }; 61 62 #define PIDHSZ 63 63 #define PIDHASH(pid) ((pid) % PIDHSZ) 64 65 #ifdef KERNEL 66 short pidhash[PIDHSZ]; 67 struct proc *pfind(); 68 struct proc *proc, *procNPROC; /* the proc table itself */ 69 int nproc; 70 71 #define NQS 32 /* 32 run queues */ 72 struct prochd { 73 struct proc *ph_link; /* linked list of running processes */ 74 struct proc *ph_rlink; 75 } qs[NQS]; 76 int whichqs; /* bit mask summarizing non-empty qs's */ 77 #endif 78 79 /* stat codes */ 80 #define SSLEEP 1 /* awaiting an event */ 81 #define SWAIT 2 /* (abandoned state) */ 82 #define SRUN 3 /* running */ 83 #define SIDL 4 /* intermediate state in process creation */ 84 #define SZOMB 5 /* intermediate state in process termination */ 85 #define SSTOP 6 /* process being traced */ 86 87 /* flag codes */ 88 #define SLOAD 0x0000001 /* in core */ 89 #define SSYS 0x0000002 /* swapper or pager process */ 90 #define SLOCK 0x0000004 /* process being swapped out */ 91 #define SSWAP 0x0000008 /* save area flag */ 92 #define STRC 0x0000010 /* process is being traced */ 93 #define SWTED 0x0000020 /* another tracing flag */ 94 #define SULOCK 0x0000040 /* user settable lock in core */ 95 #define SPAGE 0x0000080 /* process in page wait state */ 96 #define SKEEP 0x0000100 /* another flag to prevent swap out */ 97 /* was SDLYU */ 98 #define SWEXIT 0x0000400 /* working on exiting */ 99 #define SPHYSIO 0x0000800 /* doing physical i/o (bio.c) */ 100 #define SVFORK 0x0001000 /* process resulted from vfork() */ 101 #define SVFDONE 0x0002000 /* another vfork flag */ 102 #define SNOVM 0x0004000 /* no vm, parent in a vfork() */ 103 #define SPAGI 0x0008000 /* init data space on demand, from inode */ 104 #define SSEQL 0x0010000 /* user warned of sequential vm behavior */ 105 #define SUANOM 0x0020000 /* user warned of random vm behavior */ 106 #define STIMO 0x0040000 /* timing out during sleep */ 107 /* was SDETACH */ 108 #define SNUSIG 0x0100000 /* using new signal mechanism */ 109 #define SOWEUPC 0x0200000 /* owe process an addupc() call at next ast */ 110 #define SSEL 0x0400000 /* selecting; wakeup/waiting danger */ 111 #define SLOGIN 0x0800000 /* a login process (legit child of init) */ 112 #define SPTECHG 0x1000000 /* pte's for process have changed */ 113