method call support works for small programs, bigger ones hang
[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 #include "psemaphore.h"
8
9
10 #ifndef FALSE
11 #define FALSE 0
12 #endif
13
14 #ifndef TRUE
15 #define TRUE 1
16 #endif
17
18 // forward declaration of pointer type
19 typedef struct SESEcommon_t* SESEcommon_p;
20
21 // these fields are common to any SESE, and casting the
22 // generated SESE record to this can be used, because
23 // the common structure is always the first item in a
24 // customized SESE record
25 typedef struct SESEcommon_t {  
26
27   // the identifier for the class of sese's that
28   // are instances of one particular static code block
29   int classID;
30
31   // a parent waits on this semaphore when stalling on
32   // this child, the child gives it at its SESE exit
33   psemaphore stallSem;
34
35   
36   // the lock guards the following data SESE's
37   // use to coordinate with one another
38   pthread_mutex_t lock;
39
40   struct Queue*   forwardList;
41   int             unresolvedDependencies;
42
43   pthread_cond_t  doneCond;
44   int             doneExecuting;
45
46   pthread_cond_t  runningChildrenCond;
47   int             numRunningChildren;
48
49   SESEcommon_p    parent;
50
51 } SESEcommon;
52
53
54 // a thread-local stack of SESEs and function to
55 // ensure it is initialized once per thread
56 /*
57 extern __thread struct Queue* seseCallStack;
58 extern __thread pthread_once_t mlpOnceObj;
59 void mlpInitOncePerThread();
60 */
61 extern __thread SESEcommon_p seseCaller;
62
63
64 // simple mechanical allocation and 
65 // deallocation of SESE records
66 void* mlpCreateSESErecord( int size );
67 void  mlpDestroySESErecord( void* seseRecord );
68
69
70 #endif /* __MLP_RUNTIME__ */