+#include "runtime.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
+
#include "mlp_runtime.h"
#include "Queue.h"
typedef struct SESEvar_t {
- //unsigned char mode;
-
// the value when it is known will be placed
// in this location, which can be accessed
// as a variety of types
float sesetype_float;
double sesetype_double;
void* sesetype_object;
- };
-
- // a statically or dynamically known SESE
- // to gather the variable's value from
- // if source==NULL it indicates the root
- // SESE, which has no record, just normal
- // temp names
- //struct SESErecord_t* source;
- //unsigned int index;
+ };
} SESEvar;
// are instances of one particular static code block
int classID;
-
- /* JUST USE POINTER TO SESErecord AS INSTANCE ID
- // not globally unqiue, but each parent ensures that
- // its children have unique identifiers, including to
- // the parent itself
- int instanceID;
-
- // used to give out IDs to children
- int childInstanceIDs;
- */
-
// pointers to SESEs directly above or below
// in the heirarchy
- struct SESErecord_t* parent;
- struct Queue* childrenList;
+ //struct SESErecord_t* parent;
+ //struct Queue* childrenList;
+ // IMPLEMENT THIS LIKE STALLS--EVERY PARENTS EXIT MUST
+ // "STALL" on COMPLETETION OF ALL ISSUED CHILDREN, SO
+ // ALWAYS GIVE A CHILD A SEMAPHORE THAT IS ON YOUR LIST
+ // OF THINGS TO BLOCK ON AT EXIT
// for state of vars after issue
SESEvar* vars;
--- /dev/null
+#include "psemaphore.h"
+
+
+int psem_init( psemaphore* sem ) {
+ if( pthread_mutex_init( &(sem->lock), NULL ) == -1 ) { return -1; }
+ if( pthread_cond_init ( &(sem->cond), NULL ) == -1 ) { return -1; }
+ sem->signaled = 0;
+ return 0;
+}
+
+
+int psem_take( psemaphore* sem ) {
+ if( pthread_mutex_lock ( &(sem->lock) ) == -1 ) { return -1; }
+ while( !sem->signaled ) {
+ if( pthread_cond_wait ( &(sem->cond), &(sem->lock) ) == -1 ) { return -1; }
+ }
+ if( pthread_mutex_unlock( &(sem->lock) ) == -1 ) { return -1; }
+ return 0;
+}
+
+
+int psem_give( psemaphore* sem ) {
+ if( pthread_mutex_lock ( &(sem->lock) ) == -1 ) { return -1; }
+ sem->signaled = 1;
+ if( pthread_cond_signal ( &(sem->cond) ) == -1 ) { return -1; }
+ if( pthread_mutex_unlock( &(sem->lock) ) == -1 ) { return -1; }
+
+}
+
+
--- /dev/null
+#ifndef ___PSEMAPHORE_H__
+#define ___PSEMAPHORE_H__
+
+#include <pthread.h>
+
+
+typedef struct psemaphore_t {
+ pthread_mutex_t lock;
+ pthread_cond_t cond;
+ int signaled;
+} psemaphore;
+
+
+int psem_init( psemaphore* sem );
+int psem_take( psemaphore* sem );
+int psem_give( psemaphore* sem );
+
+
+#endif // ___PSEMAPHORE_H__
int y = 1;
sese fi {
- if( true ) {
+ //if( true ) {
x = y + 2;
y = 3;
- }
+ //}
}
*/
+ /*
// ADD BACK IN LATER, TO TEST STALLS
// shouldn't cause a stall
- //int z = x;
+ int z = x;
// stall and get values for y and z
x = x + 1;
// all of these should proceed without stall
y = y + 1;
x = x + 1;
- //z = z + 1;
-
+ z = z + 1;
+ */
// see that values from sese fi are
// forwarded to this sibling
//sese fo {
// expecting x=5, y=4
System.out.println( "x="+x+", y="+y );
- //}
+ //}