about to make lots of changes to system, just committing this stable compilation...
[IRC.git] / Robust / src / Runtime / mlp_runtime.h
1 #ifndef __MLP_RUNTIME__
2 #define __MLP_RUNTIME__
3
4
5 #include <pthread.h>
6 #include "Queue.h"
7
8
9 // value mode means the variable's value
10 // is present in the SESEvar struct
11 #define SESEvar_MODE_VALUE   3001
12
13 // static move means the variable's value
14 // will come from a statically known SESE
15 #define SESEvar_MODE_STATIC  3002
16
17 // dynamic mode means the variable's value
18 // will come from an SESE, and the exact
19 // SESE will be determined at runtime
20 #define SESEvar_MODE_DYNAMIC 3003
21
22
23 // a forward delcaration for SESEvar
24 struct SESErecord;
25
26
27 struct SESEvar {
28   unsigned char mode;
29
30   // the value when it is known will be placed
31   // in this location, which can be accessed
32   // as a variety of types
33   union {
34     char      sesetype_byte;
35     int       sesetype_boolean;
36     short     sesetype_short;
37     int       sesetype_int;
38     long long sesetype_long;
39     short     sesetype_char;
40     float     sesetype_float;
41     double    sesetype_double;
42     void*     sesetype_object;
43   };
44   
45   // a statically or dynamically known SESE
46   // to gather the variable's value from
47   // if source==NULL it indicates the root
48   // SESE, which has no record, just normal
49   // temp names
50   struct SESErecord* source;
51   unsigned int index;
52 };
53
54
55 struct SESErecord {  
56   // the identifier for the class of sese's that
57   // are instances of one particular static code block
58   int classID;
59
60   // not globally unqiue, but each parent ensures that
61   // its children have unique identifiers, including to
62   // the parent itself
63   int instanceID;
64
65   // for state of vars after issue
66   struct SESEvar* vars;
67   
68   // when this sese is ready to be invoked,
69   // allocate and fill in this structure, and
70   // the primitives will be passed out of the
71   // above var array at the call site
72   void* paramStruct;
73
74   // use a list of SESErecords and a lock to let
75   // consumers tell this SESE who wants values
76   // forwarded to it
77   pthread_mutex_t forwardListLock;// = PTHREAD_MUTUX_INITIALIZER;
78   struct Queue* forwardList;
79 };
80
81
82 void mlpInit();
83
84 struct SESErecord* mlpGetCurrent();
85 struct SESErecord* mlpSchedule();
86
87 void mlpIssue     ( struct SESErecord* sese );
88 void mlpStall     ( struct SESErecord* sese );
89 void mlpNotifyExit( struct SESErecord* sese );
90
91
92 extern struct SESErecord* rootsese;
93
94
95 #endif /* __MLP_RUNTIME__ */