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