Documentation fixes
[vlp.git] / src / int / process.h
1 #include        "queue.h"
2
3
4 /**
5  * @defgroup
6  * @brief Process management definitions
7  */
8 /** @{ */
9
10 /** maximum number of processes on one node */
11 #define MAXPROCESS       64
12
13 /** maximum number of waiting messages */
14 #define MAXMSGQUEUE      16
15
16 /** message length defined by me (PS) */
17 #define MSGLENGTH       256
18 /** @} */
19
20 /**
21  * @defgroup
22  * @brief Process states
23  */
24 /** @{ */
25 /* during generation of process object */
26 #define GENERATING      0
27
28 /** non-active process (suspended by STOP) */
29 #define STOPPED         1
30
31 /** active process (ready to execute) */
32 #define EXECUTING       2
33
34 /** waiting for NEW of another process */
35 #define WAITFORNEW      3
36
37 /** waiting for remote procedure call */
38 #define WAITFORRPC      4
39
40 /** during execution of ACCEPT statement */
41 #define ACCEPTING       5
42
43 /** waiting for process prototype */
44 #define WAITASKPRO      6
45 /** @} */
46
47 /** Process descriptor */
48 typedef struct
49 {
50         /* TRUE if in use by some process */
51         bool used;
52
53         /* process mark for proper detecting of none */
54         word mark;
55
56         /* process state */
57         int status;
58
59         /* process prototype number */
60         word prot;
61
62         /* pointer to memory array */
63         memory M;
64
65         union value param[MAXPARAM];
66
67         /* instruction counter */
68         word ic;
69
70         /* trace line number */
71         word trlnumber;
72
73         /* first word of object area */
74         word lower;
75
76         /* last word in memory */
77         word upper;
78
79         /* last word used by objects */
80         word lastused;
81
82         /* first word used by dictionary */
83         word lastitem;
84
85         /* head of free dictionary item list */
86         word freeitem;
87
88         /* head of killed object list for size > 2 */
89         word headk;
90
91         /* head of killed object list for size = 2 */
92         word headk2;
93
94         /* am of process object */
95         word prochead;
96
97         /* process object virtual address */
98         virtaddr procref;
99
100         /* remote process or procedure template */
101         virtaddr template;
102
103         /* pointers to current object */
104         word c1, c2;
105
106         /* adress of object just left */
107         virtaddr backobj;
108
109         /* used for LBLOCK1, LBLOCK2, LBLOCK3 */
110         word blck1, blck2;
111
112         /* queue of messages for this process */
113         queue msgqueue;
114
115         /* queue of disabled RPC messages */
116         queue rpcwait;
117
118         /* stack of set of enabled remote procedures */
119         stack rpcmask;
120
121         /* next allocate will forace compact */
122         bool force_compactification;
123
124         /* table of pointers to processes in process */
125         word *hash;
126         word hash_size;
127 } procdescr;
128
129
130 /**
131  * Message type:
132  * \defgroup MessageType Message type
133  * @{
134  */
135
136 /** error signal */
137 #define ERRSIG   0
138 /** resume request */
139 #define RESUME   1
140 /** create new process request */
141 #define CREATE   2
142 /** create process acknowledge */
143 #define CREACK   3
144 /** kill process */
145 #define KILLPR   4
146 /** remote procedure call request */
147 #define RPCALL   5
148 /** remote procedure return */
149 #define RPCACK   6
150 /** ask for process prototype */
151 #define ASKPRO   7
152 /** answer with process prototype */
153 #define PROACK   8
154
155 /** @} */
156
157 typedef struct {
158         word node;
159         word pix;
160         word mark;
161 } procaddr;
162
163 struct ctrlmsg
164 {
165         /** address of the sender and */
166         procaddr sender;
167
168         /** receiver of the message */
169         procaddr receiver;
170
171         /** message type */
172         int type;
173
174         /** prototype or error signal number */
175         int par;
176 };
177
178 #define MAXPROCPAR      (MSGLENGTH-sizeof(struct ctrlmsg))
179
180 typedef struct
181 {
182         struct ctrlmsg control;
183         char params[MAXPROCPAR];
184 } message;
185
186 /* Direction of copying of parameters (for moveparams()): */
187
188 #define LOADPAR         0
189 #define SAVEPAR         1
190
191 typedef char *mask;
192
193 /** process descriptor table */
194 extern procdescr process[];
195
196 /** pointer to current process descriptor */
197 extern procdescr *thisp;
198
199 /** current process index */
200 extern word thispix;
201
202 /** Round-Robin queue of ready processes */
203 extern queue ready;
204
205 /** TRUE if operating in D-Link network */
206 extern bool network;
207
208 /** queue of waiting messages */
209 extern message globmsgqueue[];
210
211 /** number of waiting messages */
212 extern int msgready;
213
214 /** pointers to message queue */
215 extern int msghead, msgtail;
216
217 /** this machine node number */
218 extern word ournode;
219
220 /** console node number */
221 extern word console;
222
223 /** TRUE if remote node */
224 extern bool remote;
225
226 /** TRUE if rescheduling is mandatory */
227 extern bool reschedule;
228
229 #if OS2
230 /** pointer to Global Info Segment */
231 extern PGINFOSEG ginf;
232 #endif
233
234
235
236 #ifndef NO_PROTOTYPES
237 void obj2mess(word *,virtaddr *,procaddr*);
238 void mess2obj(procdescr *,procaddr *,virtaddr*);
239 bool isprocess(virtaddr *);
240 void hash_find(procaddr *,virtaddr *);
241 void hash_create(procdescr *,int);
242 void hash_set(procaddr *,word);
243 #else
244 void obj2mess();
245 void mess2obj();
246 bool isprocess();
247 void hash_find();
248 void hash_create();
249 void hash_set();
250 #endif
251