xref: /original-bsd/sys/sys/proc.h (revision f0fd5f8a)
1 /*	proc.h	4.19	82/12/09	*/
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 #ifdef QUOTA
57 	struct	quota *p_quota;	/* quotas for this process (MUSH) */
58 #endif
59 #ifdef MUSH
60 	mmsgbuf	p_mb;		/* pending message */
61 	int	p_msgflgs;	/* message flags */
62 #endif
63 };
64 
65 #define	PIDHSZ		63
66 #define	PIDHASH(pid)	((pid) % PIDHSZ)
67 
68 #ifdef KERNEL
69 short	pidhash[PIDHSZ];
70 
71 struct	proc *pfind();
72 #endif
73 
74 #ifdef	KERNEL
75 struct	proc *proc, *procNPROC;	/* the proc table itself */
76 int	nproc;
77 
78 #define	NQS	32		/* 32 run queues */
79 struct	prochd {
80 	struct	proc *ph_link;	/* linked list of running processes */
81 	struct	proc *ph_rlink;
82 } qs[NQS];
83 int	whichqs;		/* bit mask summarizing non-empty qs's */
84 #endif
85 
86 /* stat codes */
87 #define	SSLEEP	1		/* awaiting an event */
88 #define	SWAIT	2		/* (abandoned state) */
89 #define	SRUN	3		/* running */
90 #define	SIDL	4		/* intermediate state in process creation */
91 #define	SZOMB	5		/* intermediate state in process termination */
92 #define	SSTOP	6		/* process being traced */
93 
94 /* flag codes */
95 #define	SLOAD	0x0000001	/* in core */
96 #define	SSYS	0x0000002	/* swapper or pager process */
97 #define	SLOCK	0x0000004	/* process being swapped out */
98 #define	SSWAP	0x0000008	/* save area flag */
99 #define	STRC	0x0000010	/* process is being traced */
100 #define	SWTED	0x0000020	/* another tracing flag */
101 #define	SULOCK	0x0000040	/* user settable lock in core */
102 #define	SPAGE	0x0000080	/* process in page wait state */
103 #define	SKEEP	0x0000100	/* another flag to prevent swap out */
104 #define	SDLYU	0x0000200	/* delayed unlock of pages */
105 #define	SWEXIT	0x0000400	/* working on exiting */
106 #define	SPHYSIO	0x0000800	/* doing physical i/o (bio.c) */
107 #define	SVFORK	0x0001000	/* process resulted from vfork() */
108 #define	SVFDONE	0x0002000	/* another vfork flag */
109 #define	SNOVM	0x0004000	/* no vm, parent in a vfork() */
110 #define	SPAGI	0x0008000	/* init data space on demand, from inode */
111 #define	SSEQL	0x0010000	/* user warned of sequential vm behavior */
112 #define	SUANOM	0x0020000	/* user warned of random vm behavior */
113 #define	STIMO	0x0040000	/* timing out during sleep */
114 /* was SDETACH */
115 #define	SNUSIG	0x0100000	/* using new signal mechanism */
116 #define	SOWEUPC	0x0200000	/* owe process an addupc() call at next ast */
117 #define	SSEL	0x0400000	/* selecting; wakeup/waiting danger */
118 #define	SLOGIN	0x0800000	/* a login process (legit child of init) */
119 #define	SPTECHG	0x1000000	/* pte's for process have changed */
120