1: /*
2: * Copyright (c) 1982, 1986 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)proc.h 7.1 (Berkeley) 6/4/86
7: */
8:
9: /*
10: * One structure allocated per active
11: * process. It contains all data needed
12: * about the process while the
13: * process may be swapped out.
14: * Other per process data (user.h)
15: * is swapped with the process.
16: */
17: struct proc {
18: struct proc *p_link; /* linked list of running processes */
19: struct proc *p_rlink;
20: struct proc *p_nxt; /* linked list of allocated proc slots */
21: struct proc **p_prev; /* also zombies, and free proc's */
22: struct pte *p_addr; /* u-area kernel map address */
23: char p_usrpri; /* user-priority based on p_cpu and p_nice */
24: char p_pri; /* priority, negative is high */
25: char p_cpu; /* cpu usage for scheduling */
26: char p_stat;
27: char p_time; /* resident time for scheduling */
28: char p_nice; /* nice for cpu usage */
29: char p_slptime; /* time since last block */
30: char p_cursig;
31: int p_sig; /* signals pending to this process */
32: int p_sigmask; /* current signal mask */
33: int p_sigignore; /* signals being ignored */
34: int p_sigcatch; /* signals being caught by user */
35: int p_flag;
36: uid_t p_uid; /* user id, used to direct tty signals */
37: short p_pgrp; /* name of process group leader */
38: short p_pid; /* unique process id */
39: short p_ppid; /* process id of parent */
40: u_short p_xstat; /* Exit status for wait */
41: struct rusage *p_ru; /* mbuf holding exit information */
42: short p_poip; /* page outs in progress */
43: short p_szpt; /* copy of page table size */
44: size_t p_tsize; /* size of text (clicks) */
45: size_t p_dsize; /* size of data space (clicks) */
46: size_t p_ssize; /* copy of stack size (clicks) */
47: size_t p_rssize; /* current resident set size in clicks */
48: size_t p_maxrss; /* copy of u.u_limit[MAXRSS] */
49: size_t p_swrss; /* resident set size before last swap */
50: swblk_t p_swaddr; /* disk address of u area when swapped */
51: caddr_t p_wchan; /* event process is awaiting */
52: struct text *p_textp; /* pointer to text structure */
53: struct pte *p_p0br; /* page table base P0BR */
54: struct proc *p_xlink; /* linked list of procs sharing same text */
55: short p_cpticks; /* ticks of cpu time */
56: float p_pctcpu; /* %cpu for this process during p_time */
57: short p_ndx; /* proc index for memall (because of vfork) */
58: short p_idhash; /* hashed based on p_pid for kill+exit+... */
59: struct proc *p_pptr; /* pointer to process structure of parent */
60: struct proc *p_cptr; /* pointer to youngest living child */
61: struct proc *p_osptr; /* pointer to older sibling processes */
62: struct proc *p_ysptr; /* pointer to younger siblings */
63: struct itimerval p_realtimer;
64: struct quota *p_quota; /* quotas for this process */
65: };
66:
67: #define PIDHSZ 64
68: #define PIDHASH(pid) ((pid) & (PIDHSZ - 1))
69:
70: #ifdef KERNEL
71: short pidhash[PIDHSZ];
72: struct proc *pfind();
73: struct proc *proc, *procNPROC; /* the proc table itself */
74: struct proc *freeproc, *zombproc, *allproc;
75: /* lists of procs in various states */
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 SOMASK 0x0000200 /* restore old mask after taking signal */
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 SOUSIG 0x0100000 /* using old 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 */
Defined variables
nproc
defined in line
76; used 4 times
proc
defined in line
73; used 46 times
- in /usr/src/sys/sys/init_main.c line
63,
163,
180-183(3),
191
- in /usr/src/sys/sys/kern_exit.c line
120-126(4),
145-156(6)
- in /usr/src/sys/sys/kern_fork.c line
172,
213,
275
- in /usr/src/sys/sys/kern_proc.c line
88(3),
107
- in /usr/src/sys/sys/kern_sig.c line
394,
598
- in /usr/src/sys/sys/kern_synch.c line
99
- in /usr/src/sys/sys/subr_xxx.c line
97
- in /usr/src/sys/sys/uipc_mbuf.c line
56
- in /usr/src/sys/sys/vm_mem.c line
201,
359,
384
- in /usr/src/sys/sys/vm_page.c line
643,
711,
791,
891,
980,
1008
- in /usr/src/sys/sys/vm_sched.c line
321,
345
- in /usr/src/sys/sys/vm_swp.c line
82,
89,
128,
151
- in /usr/src/sys/vax/machdep.c line
112
- in /usr/src/sys/vaxmba/mba.c line
412
- in /usr/src/sys/vaxuba/uba.c line
168
qs
defined in line
82; used 3 times
Defined struct's
proc
defined in line
17; used 272 times
- in line 18-21(8),
54-62(10),
72-74(6),
80-81(4)
- in /usr/src/sys/GENERIC/param.c line
71(2)
- in /usr/src/sys/conf/param.c line
71(2)
- in /usr/src/sys/sys/init_main.c line
52(2)
- in /usr/src/sys/sys/kern_clock.c line
78(2),
322(2)
- in /usr/src/sys/sys/kern_descrip.c line
214(2)
- in /usr/src/sys/sys/kern_exit.c line
51(2),
214(2)
- in /usr/src/sys/sys/kern_fork.c line
52(2),
103(2)
- in /usr/src/sys/sys/kern_mman.c line
243(2)
- in /usr/src/sys/sys/kern_proc.c line
36-38(4),
73(2),
82-91(6),
99(2)
- in /usr/src/sys/sys/kern_prot.c line
41(2),
96(2)
- in /usr/src/sys/sys/kern_resource.c line
31(2),
84(2),
129(2)
- in /usr/src/sys/sys/kern_sig.c line
86(2),
124(2),
137(2),
150(2),
196(2),
248(2),
284(2),
298(2),
523(2),
667(2),
686(2)
- in /usr/src/sys/sys/kern_synch.c line
47(2),
107(2),
126-127(4),
145(2),
221-224(4),
247(2),
301(2),
309(2),
357(2)
- in /usr/src/sys/sys/kern_time.c line
188(2),
231(2)
- in /usr/src/sys/sys/kern_xxx.c line
124(2),
200(2),
225(2),
331(2)
- in /usr/src/sys/sys/quota_subr.c line
56(2)
- in /usr/src/sys/sys/subr_log.c line
30(2)
- in /usr/src/sys/sys/subr_prf.c line
79(2)
- in /usr/src/sys/sys/sys_generic.c line
351(2),
418(2)
- in /usr/src/sys/sys/sys_process.c line
51(2)
- in /usr/src/sys/sys/tty.c line
478(2),
571(2)
- in /usr/src/sys/sys/tty_pty.c line
42(2),
320(2)
- in /usr/src/sys/sys/uipc_socket.c line
791(2)
- in /usr/src/sys/sys/uipc_socket2.c line
226(2),
272(2)
- in /usr/src/sys/sys/vm_drum.c line
175(2),
216(2),
294(2)
- in /usr/src/sys/sys/vm_mem.c line
36(2),
168-172(4)
- in /usr/src/sys/sys/vm_page.c line
72(2),
494(2),
760(2),
965(2),
1070(2),
1231(2)
- in /usr/src/sys/sys/vm_proc.c line
54(2),
87(2),
145(2),
256(2),
333(2)
- in /usr/src/sys/sys/vm_pt.c line
40(2),
80-83(4),
153(2),
170(2),
198(2),
276(2),
301(2),
352(2),
364(2),
376(2)
- in /usr/src/sys/sys/vm_sched.c line
81(2),
88(2),
352(2)
- in /usr/src/sys/sys/vm_subr.c line
32(2),
74(2),
92(2)
- in /usr/src/sys/sys/vm_swap.c line
26(2),
84(2),
166(2),
229(2)
- in /usr/src/sys/sys/vm_swp.c line
49(2),
161(2)
- in /usr/src/sys/sys/vm_text.c line
263(2),
290(2),
354(2),
367-370(4),
393(2)
- in /usr/src/sys/vax/Locore.c line
159(2),
255-258(4)
- in /usr/src/sys/vax/genassym.c line
37(4)
- in /usr/src/sys/vax/machdep.c line
112(2)
- in /usr/src/sys/vax/sys_machdep.c line
86(2)
- in /usr/src/sys/vax/trap.c line
65(2),
191(2)
- in /usr/src/sys/vaxmba/mba.c line
404(2)
- in /usr/src/sys/vaxuba/uba.c line
120(2)
- in /usr/src/sys/vaxuba/vs.c line
84(2)
Defined macros
NQS
defined in line
78; used 3 times
SIDL
defined in line
90; used 1 times
SLOAD
defined in line
95; used 20 times
- in /usr/src/sys/sys/init_main.c line
68,
182
- in /usr/src/sys/sys/kern_fork.c line
167,
269
- in /usr/src/sys/sys/kern_synch.c line
83,
267,
275,
334,
341
- in /usr/src/sys/sys/vm_sched.c line
71(2),
124,
148,
263,
405,
419
- in /usr/src/sys/sys/vm_swap.c line
59,
108,
135-137(2)
SLOCK
defined in line
97; used 4 times
SRUN
defined in line
89; used 12 times
SSEL
defined in line
117; used 6 times
SSLEEP
defined in line
87; used 10 times
SSTOP
defined in line
92; used 8 times
SSWAP
defined in line
98; used 3 times
SSYS
defined in line
96; used 5 times
STRC
defined in line
99; used 18 times
- in /usr/src/sys/sys/kern_exec.c line
89,
481
- in /usr/src/sys/sys/kern_exit.c line
59,
166-167(2),
260
- in /usr/src/sys/sys/kern_sig.c line
312,
333,
376,
439,
530,
540,
549,
557,
605,
635
- in /usr/src/sys/sys/sys_process.c line
61-66(2)
SWAIT
defined in line
88;
never used
SZOMB
defined in line
91; used 2 times
Usage of this include