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{
28 // forward declaration of pointer type
29 typedef struct SESEcommon_t* SESEcommon_p;
31 // these fields are common to any SESE, and casting the
32 // generated SESE record to this can be used, because
33 // the common structure is always the first item in a
34 // customized SESE record
35 typedef struct SESEcommon_t {
37 // the identifier for the class of sese's that
38 // are instances of one particular static code block
41 // a parent waits on this semaphore when stalling on
42 // this child, the child gives it at its SESE exit
46 // the lock guards the following data SESE's
47 // use to coordinate with one another
50 struct Queue* forwardList;
51 int unresolvedDependencies;
53 pthread_cond_t doneCond;
56 pthread_cond_t runningChildrenCond;
57 int numRunningChildren;
61 AllocSite* allocSiteArray;
62 int numRelatedAllocSites;
63 psemaphore memoryStallSiteSem;
64 struct Queue* connectedList;
69 // a thread-local stack of SESEs and function to
70 // ensure it is initialized once per thread
72 extern __thread struct Queue* seseCallStack;
73 extern __thread pthread_once_t mlpOnceObj;
74 void mlpInitOncePerThread();
76 extern __thread SESEcommon_p seseCaller;
79 // simple mechanical allocation and
80 // deallocation of SESE records
81 void* mlpCreateSESErecord( int size );
82 void mlpDestroySESErecord( void* seseRecord );
84 AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
85 ConflictNode* mlpCreateConflictNode(int id);
86 struct QueueItem* addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, void *seseRec);
90 #endif /* __MLP_RUNTIME__ */