|
|
1.1 root 1: /* (-lgl
2: * COHERENT Version 4.0
3: * Copyright (c) 1982, 1992 by Mark Williams Company.
4: * All rights reserved. May not be copied without permission.
5: -lgl) */
6: /*
7: * /usr/include/sys/proc.h
8: * Process information.
9: */
10:
11: #ifndef _PROC_H
12: #define _PROC_H
13:
14: #include <sys/types.h>
15: #include <poll.h>
16: #include <sys/timeout.h>
17:
18: /*
19: * Number of user segments.
20: */
21: #ifdef _I386
22: #define NUSEG 4
23: #else
24: #define NUSEG 6
25: #endif
26:
27: /*
28: * In core information about a process.
29: * The `p_lforw' and `p_lback' entries must not move as they must be
30: * in the same place as in the `plink' structure.
31: */
32: typedef struct proc {
33: struct proc *p_lforw; /* Working forward pointer */
34: struct proc *p_lback; /* Working backward pointer */
35: struct proc *p_nforw; /* Next forward pointer */
36: struct proc *p_nback; /* Next backward pointer */
37: struct seg *p_segp[NUSEG+1]; /* Segments */
38: unsigned p_pid; /* Process id */
39: unsigned p_ppid; /* Process id of parent */
40: unsigned p_uid; /* Effective uid */
41: unsigned p_ruid; /* Real uid */
42: unsigned p_rgid; /* Real gid */
43: unsigned p_state; /* Scheduling state */
44: unsigned p_flags; /* Flags */
45: sig_t p_ssig; /* Signals which have been set */
46: #ifdef _I386
47: sig_t p_dfsig; /* Signals which are defaulted */
48: sig_t p_hsig; /* Signals which are being held */
49: sig_t p_dsig; /* Signals which are being deferred */
50: #endif
51: sig_t p_isig; /* Signals which are being ignored */
52: char *p_event; /* Wakeup event channel */
53: unsigned p_alarm; /* Timer for alarms */
54: unsigned p_group; /* Process group */
55: dev_t p_ttdev; /* Controlling terminal */
56: unsigned p_nice; /* Nice value */
57: unsigned p_cval; /* Cpu schedule value */
58: unsigned p_sval; /* Swap schedule value */
59: int p_ival; /* Importance value */
60: unsigned p_rval; /* Response value */
61: unsigned p_lctim; /* Last time cval was updated */
62: long p_utime; /* User time (HZ) */
63: long p_stime; /* System time */
64: long p_cutime; /* Sum of childs user time */
65: long p_cstime; /* Sum of childs system time */
66: int p_exit; /* Exit status */
67: event_t *p_polls; /* Enabled polls */
68: TIM p_polltim; /* Poll timer */
69: TIM p_alrmtim; /* Alarm timer */
70: #ifdef _I386
71: struct rlock *p_prl; /* Pending record lock */
72: #endif
73: } PROC;
74:
75: /*
76: * Segment indices.
77: */
78: #ifdef _I386
79: #define SIUSERP 0 /* User area segment */
80: #define SISTEXT 1 /* Shared text segment */
81: #define SIPDATA 2 /* Private data segment */
82: #define SISTACK 3 /* Stack segment */
83: #define SIAUXIL 4 /* Auxiliary segment */
84: #define SIBSS 0 /* overlay of SIUSERP [coh/exec.c] */
85: #else
86: #define SIUSERP 0 /* User area segment */
87: #define SISTACK 1 /* Stack segment */
88: #define SISTEXT 2 /* Shared text segment */
89: #define SIPTEXT 3 /* Private text segment */
90: #define SISDATA 4 /* Shared data segment */
91: #define SIPDATA 5 /* Private data segment */
92: #define SIAUXIL 6 /* Auxiliary segment */
93: #endif
94:
95: /*
96: * Status of process (p_state).
97: */
98: #define PSSLEEP 1 /* Sleeping */
99: #define PSRUN 2 /* Running */
100: #define PSDEAD 3 /* Process is exiting */
101:
102: /*
103: * Flags (p_flags).
104: */
105: #define PFCORE 0x0001 /* Process is in core */
106: #define PFLOCK 0x0002 /* Process is locked in core */
107: #define PFSWIO 0x0004 /* Swap I/O in progress */
108: #define PFSWAP 0x0008 /* Process is swapped out */
109: #define PFWAIT 0x0010 /* Process is stopped (not waited) */
110: #define PFSTOP 0x0020 /* Process is stopped (waited on) */
111: #define PFTRAC 0x0040 /* Process is being traced */
112: #define PFKERN 0x0080 /* Kernel process */
113: #define PFAUXM 0x0100 /* Auxiliary segments in memory */
114: #define PFDISP 0x0200 /* Dispatch at earliest convenience */
115: #define PFNDMP 0x0400 /* Command mode forbids dump */
116:
117: #ifdef QWAKEUP
118: #define PFWAKE 0x0800 /* Wakeup requested */
119: extern int wakeup2();
120: extern int ntowake; /* Wakeup pending */
121: #endif
122:
123: /*
124: * Values of nice.
125: */
126: #define MINNICE 0 /* Minimum value of nice */
127: #define DEFNICE 20 /* Default nice value */
128: #define MAXNICE 40 /* Maximum nice value */
129:
130: /*
131: * Number of entries in sleep/wakeup queue.
132: */
133: #ifdef _I386
134: #define NHPLINK 97
135: #else
136: #define NHPLINK 32
137: #endif
138:
139: /*
140: * Sleep/wakeup queues.
141: */
142: typedef struct plink {
143: struct proc *p_lforw; /* Working forward pointer */
144: struct proc *p_lback; /* Working backward pointer */
145: } PLINK;
146: #endif
147:
148: #ifdef KERNEL
149:
150: #define SELF cprocp
151: #define locked(gate) ((gate)[0])
152: #ifndef _I386
153: #define p_u p_segp[SIUSERP]
154: #endif
155: /*
156: * Functions.
157: */
158: extern int idle();
159: extern PROC *process();
160: extern int wakeup();
161:
162: /*
163: * Global variables.
164: */
165: extern int quantum; /* Current quantum */
166: extern int disflag; /* Dispatch soon as possible */
167: extern int intflag; /* We are in an interrupt */
168: extern int cpid; /* Current process id */
169: extern GATE pnxgate; /* Gate for p_next */
170: extern PROC procq; /* Process queue */
171: extern PROC *iprocp; /* Idle process struct */
172: extern PROC *eprocp; /* Init process struct */
173: extern PROC *cprocp; /* Current process */
174: extern PLINK linkq[NHPLINK]; /* Sleep/wakeup hash queue */
175:
176: #ifndef NOMONITOR
177: extern int swmflag; /* Monitor swapper */
178: #endif
179:
180: /*
181: * Function to hash a wakeup channel.
182: * Most channels are even.
183: */
184: #ifdef _I386
185: #define hash(e) ((unsigned)(e) % NHPLINK)
186: #else
187: #define hash(e) ((((unsigned)(e))>>1)%NHPLINK)
188: #endif
189: #endif
190:
191: /* end of sys/proc.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.