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