Added upstream version.
[vlp.git] / int / process.h
1 #include        "queue.h"
2
3
4 /* Process management definitions : */
5
6 #define MAXPROCESS       64  /* maximum number of processes on one node */
7 #define MAXMSGQUEUE      16 /* maximum number of waiting messages */
8
9 #define MSGLENGTH       256   /* message length defined by me (PS) */
10
11
12 /* Process state : */
13
14 #define GENERATING      0    /* during generation of process object */
15 #define STOPPED         1      /* non-active process (suspended by STOP) */
16 #define EXECUTING       2     /* active process (ready to execute) */
17 #define WAITFORNEW      3    /* waiting for NEW of another process */
18 #define WAITFORRPC      4    /* waiting for remote procedure call */
19 #define ACCEPTING       5     /* during execution of ACCEPT statement */
20 #define WAITASKPRO      6    /* waiting for process prototype */
21
22 /* Process descriptor : */
23
24 typedef struct
25 {
26     bool used;           /* TRUE if in use by some process */
27     word mark;           /* process mark for proper detecting of none */
28     int status;                /* process state */
29     word prot;           /* process prototype number */
30     memory M;      /* pointer to memory array */
31     union value param[ MAXPARAM ];
32     word ic;         /* instruction counter */
33     word trlnumber;         /* trace line number */
34     word lower;                /* first word of object area */
35     word upper;                /* last word in memory */
36     word lastused;           /* last word used by objects */
37     word lastitem;           /* first word used by dictionary */
38     word freeitem;           /* head of free dictionary item list */
39     word headk;                /* head of killed object list for size > 2 */
40     word headk2;               /* head of killed object list for size = 2 */
41     word prochead;         /* am of process object */
42     virtaddr procref;    /* process object virtual address */
43     virtaddr template;   /* remote process or procedure template */
44     word c1, c2;               /* pointers to current object */
45     virtaddr backobj;     /* adress of object just left */
46     word blck1, blck2;          /* used for LBLOCK1, LBLOCK2, LBLOCK3 */
47     queue msgqueue;         /* queue of messages for this process */
48     queue rpcwait;           /* queue of disabled RPC messages */
49     stack rpcmask;           /* stack of set of enabled remote procedures */
50     bool force_compactification; /* next allocate will forace compact... */
51     word *hash;                /* table of pointers to processes in process */
52     word hash_size;
53 } procdescr;
54
55
56 /* Message type : */
57
58 #define ERRSIG   0       /* error signal */
59 #define RESUME   1       /* resume request */
60 #define CREATE   2       /* create new process request */
61 #define CREACK   3       /* create process acknowledge */
62 #define KILLPR   4       /* kill process */
63 #define RPCALL   5       /* remote procedure call request */
64 #define RPCACK   6       /* remote procedure return */
65 #define ASKPRO   7       /* ask for process prototype */
66 #define PROACK   8       /* answer with process prototype */
67
68 typedef struct {
69     word node;
70     word pix;
71     word mark;
72 } procaddr;
73
74 struct ctrlmsg
75 {
76     procaddr sender;       /* address of the sender and */
77     procaddr receiver;   /* receiver of the message */
78     int type;      /* message type */
79     int par;         /* prototype or error signal number */
80 };
81
82 #define MAXPROCPAR      (MSGLENGTH-sizeof(struct ctrlmsg))
83
84 typedef struct
85 {
86     struct ctrlmsg control;
87     char params[ MAXPROCPAR ];
88 } message;
89
90 /* Direction of copying of parameters (for moveparams()) : */
91
92 #define LOADPAR         0
93 #define SAVEPAR         1
94
95 typedef char *mask;
96
97 extern procdescr process[];     /* process descriptor table              */
98 extern procdescr *thisp;        /* pointer to current process descriptor */
99 extern word thispix;            /* current process index                 */
100 extern queue ready;             /* Round-Robin queue of ready processes  */
101 extern bool network;            /* TRUE if operating in D-Link network   */
102 extern message globmsgqueue[];  /* queue of waiting messages             */
103 extern int msgready;            /* number of waiting messages            */
104 extern int msghead, msgtail;    /* pointers to message queue             */
105 extern word ournode;            /* this machine node number              */
106 extern word console;            /* console node number                   */
107 extern bool remote;             /* TRUE if remote node                   */
108 extern bool reschedule;         /* TRUE if rescheduling is mandatory     */
109
110 #if OS2
111 extern PGINFOSEG ginf;          /* pointer to Global Info Segment */
112 #endif
113
114
115
116 #ifndef NO_PROTOTYPES
117 void obj2mess(word *,virtaddr *,procaddr*);
118 void mess2obj(procdescr *,procaddr *,virtaddr*);
119 bool isprocess(virtaddr *);
120 void hash_find(procaddr *,virtaddr *);
121 void hash_create(procdescr *,int);
122 void hash_set(procaddr *,word);
123 #else
124 void obj2mess();
125 void mess2obj();
126 bool isprocess();
127 void hash_find();
128 void hash_create();
129 void hash_set();
130 #endif
131