use Berkeley specific copyright notice
[unix-history] / usr / src / sys / sys / proc.h
CommitLineData
da7c5cc6 1/*
1810611d 2 * Copyright (c) 1982, 1986 Regents of the University of California.
da7c5cc6
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
0cc0777f 6 * @(#)proc.h 7.3 (Berkeley) %G%
da7c5cc6 7 */
5cb51551 8
0cc0777f
MT
9/*
10 * One structure allocated per session.
11 */
12struct session {
13 struct proc *s_leader; /* pointer to session leader */
14 short s_count; /* number of pgrps in session */
15};
16
17/*
18 * One structure allocated per process group.
19 */
20struct pgrp {
21 struct pgrp *pg_hforw; /* forward link in hash bucket */
22 struct proc *pg_mem; /* pointer to pgrp members */
23 struct session *pg_session; /* pointer to session */
24 pid_t pg_id; /* pgrp id */
25 short pg_jobc; /* # procs qualifying pgrp for job control */
26};
27
5cb51551
BJ
28/*
29 * One structure allocated per active
30 * process. It contains all data needed
31 * about the process while the
32 * process may be swapped out.
33 * Other per process data (user.h)
34 * is swapped with the process.
5cb51551 35 */
f9094bc4 36struct proc {
5cb51551
BJ
37 struct proc *p_link; /* linked list of running processes */
38 struct proc *p_rlink;
40e2c1d3
SL
39 struct proc *p_nxt; /* linked list of allocated proc slots */
40 struct proc **p_prev; /* also zombies, and free proc's */
5cb51551
BJ
41 struct pte *p_addr; /* u-area kernel map address */
42 char p_usrpri; /* user-priority based on p_cpu and p_nice */
43 char p_pri; /* priority, negative is high */
44 char p_cpu; /* cpu usage for scheduling */
45 char p_stat;
46 char p_time; /* resident time for scheduling */
47 char p_nice; /* nice for cpu usage */
48 char p_slptime; /* time since last block */
36c28aee 49 char p_cursig;
40dc6933
SL
50 int p_sig; /* signals pending to this process */
51 int p_sigmask; /* current signal mask */
52 int p_sigignore; /* signals being ignored */
53 int p_sigcatch; /* signals being caught by user */
36c28aee 54 int p_flag;
adc65074 55 uid_t p_uid; /* user id, used to direct tty signals */
0cc0777f
MT
56 pid_t p_pid; /* unique process id */
57 pid_t p_ppid; /* process id of parent */
ae89c651 58 u_short p_xstat; /* Exit status for wait */
f9094bc4 59 struct rusage *p_ru; /* mbuf holding exit information */
aa2930e9
SL
60 short p_poip; /* page outs in progress */
61 short p_szpt; /* copy of page table size */
5cb51551
BJ
62 size_t p_tsize; /* size of text (clicks) */
63 size_t p_dsize; /* size of data space (clicks) */
64 size_t p_ssize; /* copy of stack size (clicks) */
65 size_t p_rssize; /* current resident set size in clicks */
7196a349 66 size_t p_maxrss; /* copy of u.u_limit[MAXRSS] */
5cb51551
BJ
67 size_t p_swrss; /* resident set size before last swap */
68 swblk_t p_swaddr; /* disk address of u area when swapped */
69 caddr_t p_wchan; /* event process is awaiting */
70 struct text *p_textp; /* pointer to text structure */
5cb51551
BJ
71 struct pte *p_p0br; /* page table base P0BR */
72 struct proc *p_xlink; /* linked list of procs sharing same text */
9cf7e873
BJ
73 short p_cpticks; /* ticks of cpu time */
74 float p_pctcpu; /* %cpu for this process during p_time */
5cb51551
BJ
75 short p_ndx; /* proc index for memall (because of vfork) */
76 short p_idhash; /* hashed based on p_pid for kill+exit+... */
36c28aee 77 struct proc *p_pptr; /* pointer to process structure of parent */
7a5bb6a6
RE
78 struct proc *p_cptr; /* pointer to youngest living child */
79 struct proc *p_osptr; /* pointer to older sibling processes */
80 struct proc *p_ysptr; /* pointer to younger siblings */
0cc0777f
MT
81 struct pgrp *p_pgrp; /* pointer to process group */
82#define p_session p_pgrp->pg_session
83#define p_pgid p_pgrp->pg_id
84 struct proc *p_pgrpnxt; /* pointer to next process in process group */
af0b24db 85 struct itimerval p_realtimer;
aa2930e9 86 struct quota *p_quota; /* quotas for this process */
22a22bd0
MK
87#if defined(tahoe)
88 int p_ckey; /* code cache key */
89 int p_dkey; /* data cache key */
90#endif
5cb51551
BJ
91};
92
40e2c1d3
SL
93#define PIDHSZ 64
94#define PIDHASH(pid) ((pid) & (PIDHSZ - 1))
5cb51551
BJ
95
96#ifdef KERNEL
0cc0777f 97pid_t pidhash[PIDHSZ];
5cb51551 98struct proc *pfind();
0cc0777f
MT
99struct pgrp *pgrphash[PIDHSZ];
100struct pgrp *pgfind(); /* find process group by id */
a0eab615 101struct proc *proc, *procNPROC; /* the proc table itself */
40e2c1d3
SL
102struct proc *freeproc, *zombproc, *allproc;
103 /* lists of procs in various states */
a0eab615 104int nproc;
5cb51551 105
5cb51551
BJ
106#define NQS 32 /* 32 run queues */
107struct prochd {
108 struct proc *ph_link; /* linked list of running processes */
109 struct proc *ph_rlink;
110} qs[NQS];
111int whichqs; /* bit mask summarizing non-empty qs's */
0cc0777f
MT
112
113#define SESS_LEADER(p) ((p)->p_session->s_leader == (p))
114#define PGRP_JOBC(p) (((p)->p_pgrp != (p)->p_pptr->p_pgrp) && \
115 ((p)->p_session == (p)->p_pptr->p_session))
5cb51551
BJ
116#endif
117
118/* stat codes */
119#define SSLEEP 1 /* awaiting an event */
120#define SWAIT 2 /* (abandoned state) */
121#define SRUN 3 /* running */
122#define SIDL 4 /* intermediate state in process creation */
123#define SZOMB 5 /* intermediate state in process termination */
124#define SSTOP 6 /* process being traced */
125
126/* flag codes */
7a5bb6a6
RE
127#define SLOAD 0x0000001 /* in core */
128#define SSYS 0x0000002 /* swapper or pager process */
129#define SLOCK 0x0000004 /* process being swapped out */
130#define SSWAP 0x0000008 /* save area flag */
131#define STRC 0x0000010 /* process is being traced */
132#define SWTED 0x0000020 /* another tracing flag */
133#define SULOCK 0x0000040 /* user settable lock in core */
134#define SPAGE 0x0000080 /* process in page wait state */
135#define SKEEP 0x0000100 /* another flag to prevent swap out */
40dc6933 136#define SOMASK 0x0000200 /* restore old mask after taking signal */
7a5bb6a6
RE
137#define SWEXIT 0x0000400 /* working on exiting */
138#define SPHYSIO 0x0000800 /* doing physical i/o (bio.c) */
139#define SVFORK 0x0001000 /* process resulted from vfork() */
140#define SVFDONE 0x0002000 /* another vfork flag */
141#define SNOVM 0x0004000 /* no vm, parent in a vfork() */
142#define SPAGI 0x0008000 /* init data space on demand, from inode */
143#define SSEQL 0x0010000 /* user warned of sequential vm behavior */
144#define SUANOM 0x0020000 /* user warned of random vm behavior */
145#define STIMO 0x0040000 /* timing out during sleep */
8673a2cb 146/* was SDETACH */
40dc6933 147#define SOUSIG 0x0100000 /* using old signal mechanism */
ded22f45 148#define SOWEUPC 0x0200000 /* owe process an addupc() call at next ast */
7a5bb6a6
RE
149#define SSEL 0x0400000 /* selecting; wakeup/waiting danger */
150#define SLOGIN 0x0800000 /* a login process (legit child of init) */
ae89c651 151#define SPTECHG 0x1000000 /* pte's for process have changed */
0cc0777f
MT
152#define STRCSYS 0x2000000 /* tracing system calls */
153#define STRCSYSI 0x4000000 /* tracing system calls - inherited */
154#define SEXEC 0x8000000 /* process called exec */