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