initial commit for adding memory conflicts feature to the SESE runtime.
[IRC.git] / Robust / src / Runtime / mlp_runtime.c
1 #include "runtime.h"
2
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <assert.h>
6
7 #include "mem.h"
8 #include "Queue.h"
9 #include "mlp_runtime.h"
10 #include "workschedule.h"
11
12
13 /*
14 __thread struct Queue* seseCallStack;
15 __thread pthread_once_t mlpOnceObj = PTHREAD_ONCE_INIT;
16 void mlpInitOncePerThread() {
17   seseCallStack = createQueue();
18 }
19 */
20 __thread SESEcommon_p seseCaller;
21
22
23 void* mlpAllocSESErecord( int size ) {
24   void* newrec = RUNMALLOC( size );  
25   return newrec;
26 }
27
28
29 void mlpFreeSESErecord( void* seseRecord ) {
30   RUNFREE( seseRecord );
31 }
32
33 AllocSite* mlpCreateAllocSiteArray(int numAllocSites){
34   int i;
35   AllocSite* newAllocSite=(AllocSite*)RUNMALLOC( sizeof( AllocSite ) * numAllocSites );
36   for(i=0; i<numAllocSites; i++){
37     newAllocSite[i].waitingQueue=createQueue();
38   }
39   return newAllocSite;
40 }
41
42 void addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, int allocID, void *seseRec){
43   
44   int i;
45   for(i=0;i<numAllocSites;i++){
46     if(allocSiteArray[i].id==allocID){
47       addNewItemBack(allocSiteArray[i].waitingQueue,seseRec);
48       //printf("add new item %d into waiting queue:%d\n",((SESEcommon*)seseRec)->classID,allocID);
49       break;
50     }
51   }
52
53 }