changes.
[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 // each allocation site nees the following
19 typedef struct AllocSite_t{
20   long id;
21   struct Queue* waitingQueue;
22 } AllocSite;
23
24 // forward declaration of pointer type
25 typedef struct SESEcommon_t* SESEcommon_p;
26
27 // these fields are common to any SESE, and casting the
28 // generated SESE record to this can be used, because
29 // the common structure is always the first item in a
30 // customized SESE record
31 typedef struct SESEcommon_t {  
32
33   // the identifier for the class of sese's that
34   // are instances of one particular static code block
35   int classID;
36
37   // a parent waits on this semaphore when stalling on
38   // this child, the child gives it at its SESE exit
39   psemaphore stallSem;
40
41   
42   // the lock guards the following data SESE's
43   // use to coordinate with one another
44   pthread_mutex_t lock;
45
46   struct Queue*   forwardList;
47   int             unresolvedDependencies;
48
49   pthread_cond_t  doneCond;
50   int             doneExecuting;
51
52   pthread_cond_t  runningChildrenCond;
53   int             numRunningChildren;
54
55   SESEcommon_p    parent;
56
57   AllocSite* allocSiteArray;
58   int numRelatedAllocSites;
59   psemaphore memoryStallSiteSem;
60
61 } SESEcommon;
62
63
64 // a thread-local stack of SESEs and function to
65 // ensure it is initialized once per thread
66 /*
67 extern __thread struct Queue* seseCallStack;
68 extern __thread pthread_once_t mlpOnceObj;
69 void mlpInitOncePerThread();
70 */
71 extern __thread SESEcommon_p seseCaller;
72
73
74 // simple mechanical allocation and 
75 // deallocation of SESE records
76 void* mlpCreateSESErecord( int size );
77 void  mlpDestroySESErecord( void* seseRecord );
78
79 AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
80
81
82 #endif /* __MLP_RUNTIME__ */