#include <pthread.h>
#include "Queue.h"
#include "psemaphore.h"
-
+#include "mlp_lock.h"
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
+// each allocation site needs the following
+typedef struct AllocSite_t{
+ long id;
+ struct Queue* waitingQueue;
+} AllocSite;
+
+typedef struct ConflictNode_t{
+ int id;
+} ConflictNode;
+
+
// forward declaration of pointer type
typedef struct SESEcommon_t* SESEcommon_p;
pthread_mutex_t lock;
struct Queue* forwardList;
- int unresolvedDependencies;
+ volatile int unresolvedDependencies;
pthread_cond_t doneCond;
int doneExecuting;
SESEcommon_p parent;
+ AllocSite* allocSiteArray;
+ int numRelatedAllocSites;
+ psemaphore memoryStallSiteSem;
+ struct Queue* connectedList;
+ int numRelatedWaitingQueue;
+ int waitingQueueItemID;
+
} SESEcommon;
+typedef struct WaitingElement_t{
+ void* seseRec;
+ int status;
+ int id;
+ struct Queue* list;
+} WaitingElement;
+
+// a thread-local stack of SESEs and function to
+// ensure it is initialized once per thread
+/*
+extern __thread struct Queue* seseCallStack;
+extern __thread pthread_once_t mlpOnceObj;
+void mlpInitOncePerThread();
+*/
+extern __thread SESEcommon_p seseCaller;
+
+
// simple mechanical allocation and
// deallocation of SESE records
void* mlpCreateSESErecord( int size );
void mlpDestroySESErecord( void* seseRecord );
+AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
+ConflictNode* mlpCreateConflictNode(int id);
+int addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, WaitingElement* wElement);
+WaitingElement* mlpCreateWaitingElement(int status, void* seseToIssue, struct Queue* queue, int id);
+void* mlpAllocSESErecord( int size );
#endif /* __MLP_RUNTIME__ */