fix the 64 bit clean bug with mlp
[IRC.git] / Robust / src / Runtime / mlp_runtime.h
index 859a430bffdf8f5141ab58243ac34b2a08a00ff0..cbf8858cc5960e81bbe25773a40466ef4fdd4ab5 100644 (file)
@@ -5,7 +5,7 @@
 #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;
 
@@ -38,7 +49,7 @@ typedef struct SESEcommon_t {
   pthread_mutex_t lock;
 
   struct Queue*   forwardList;
-  int             unresolvedDependencies;
+  volatile int             unresolvedDependencies;
 
   pthread_cond_t  doneCond;
   int             doneExecuting;
@@ -48,13 +59,42 @@ typedef struct SESEcommon_t {
 
   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__ */