1 #ifndef __MLP_RUNTIME__
2 #define __MLP_RUNTIME__
7 #include "psemaphore.h"
18 // each allocation site needs the following
19 typedef struct AllocSite_t{
21 struct Queue* waitingQueue;
24 typedef struct ConflictNode_t{
29 // forward declaration of pointer type
30 typedef struct SESEcommon_t* SESEcommon_p;
32 // these fields are common to any SESE, and casting the
33 // generated SESE record to this can be used, because
34 // the common structure is always the first item in a
35 // customized SESE record
36 typedef struct SESEcommon_t {
38 // the identifier for the class of sese's that
39 // are instances of one particular static code block
42 // a parent waits on this semaphore when stalling on
43 // this child, the child gives it at its SESE exit
47 // the lock guards the following data SESE's
48 // use to coordinate with one another
51 struct Queue* forwardList;
52 volatile int unresolvedDependencies;
54 pthread_cond_t doneCond;
57 pthread_cond_t runningChildrenCond;
58 int numRunningChildren;
62 AllocSite* allocSiteArray;
63 int numRelatedAllocSites;
64 psemaphore memoryStallSiteSem;
65 struct Queue* connectedList;
66 int numRelatedWaitingQueue;
67 int waitingQueueItemID;
69 pthread_cond_t stallDone;
74 typedef struct WaitingElement_t{
82 // a thread-local stack of SESEs and function to
83 // ensure it is initialized once per thread
85 extern __thread struct Queue* seseCallStack;
86 extern __thread pthread_once_t mlpOnceObj;
87 void mlpInitOncePerThread();
89 extern __thread SESEcommon_p seseCaller;
92 // simple mechanical allocation and
93 // deallocation of SESE records
94 void* mlpCreateSESErecord( int size );
95 void mlpDestroySESErecord( void* seseRecord );
97 AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
98 ConflictNode* mlpCreateConflictNode(int id);
99 int addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, WaitingElement* wElement);
100 WaitingElement* mlpCreateWaitingElement(int status, void* seseToIssue, struct Queue* queue, int id);
101 void* mlpAllocSESErecord( int size );
104 #endif /* __MLP_RUNTIME__ */