7 #include "mlp_runtime.h"
15 // the root sese is accessible globally so
16 // buildcode can generate references to it
20 // the issuedQ, in this simple version, spits
21 // out SESErecord's in the order they were issued
22 static struct Queue* issuedQ;
25 // the class_age2instance maps an SESE class id and
26 // age value to a particular SESErecord instance
27 static SESErecord** class_age2instance;
30 // each core/pthread should have a current SESE
31 static SESErecord* current;
34 SESErecord* mlpCreateSESErecord( int classID,
41 SESErecord* newrec = malloc( sizeof( SESErecord ) );
43 newrec->classID = classID;
44 //newrec->instanceID = instanceID;
45 //newrec->childInstanceIDs = 0;
46 newrec->parent = parent;
47 newrec->childrenList = createQueue();
48 newrec->vars = (SESEvar*) malloc( sizeof( SESEvar ) *
51 newrec->paramStruct = paramStruct;
52 newrec->forwardList = createQueue();
53 newrec->doneExecuting = FALSE;
54 newrec->startedExecuting = FALSE;
56 newrec->startCondVar = (pthread_cond_t*) malloc( sizeof( pthread_cond_t ) );
57 newrec->startCondVarLock = (pthread_mutex_t*) malloc( sizeof( pthread_mutex_t ) );
58 newrec->forwardListLock = (pthread_mutex_t*) malloc( sizeof( pthread_mutex_t ) );
60 pthread_cond_init ( newrec->startCondVar, NULL );
61 pthread_mutex_init( newrec->startCondVarLock, NULL );
62 pthread_mutex_init( newrec->forwardListLock, NULL );
68 void mlpDestroySESErecord( SESErecord* sese ) {
70 pthread_cond_destroy ( sese->startCondVar );
71 pthread_mutex_destroy( sese->startCondVarLock );
72 pthread_mutex_destroy( sese->forwardListLock );
74 free ( sese->startCondVar );
75 free ( sese->startCondVarLock );
76 free ( sese->forwardListLock );
78 freeQueue( sese->forwardList );
79 freeQueue( sese->childrenList );
85 void mlpInit( int totalNumSESEs, int maxSESEage ) {
87 issuedQ = createQueue();
89 class_age2instance = (SESErecord**) malloc( sizeof( SESErecord* ) *
98 SESErecord* mlpGetCurrent() {
103 void mlpIssue( SESErecord* sese ) {
104 addNewItem( issuedQ, (void*) sese );
108 SESErecord* mlpSchedule() {
109 assert( !isEmpty( issuedQ ) );
110 return (SESErecord*) getItem( issuedQ );
114 void mlpStall( SESErecord* sese ) {
119 void mlpNotifyExit( SESErecord* sese ) {