# HG changeset patch # User Sean Halle # Date 1373492944 25200 # Node ID b02b346814141f4ffad60338eb542f388402a14f # Parent 7b6f8cf08b1f7650cf3618da91e6edee1e620076 VReo V2 -- saves checker and doer fn with the port, where triggered diff -r 7b6f8cf08b1f -r b02b34681414 PR.c --- a/PR.c Wed Jun 12 14:12:06 2013 -0700 +++ b/PR.c Wed Jul 10 14:49:04 2013 -0700 @@ -232,9 +232,11 @@ process->executionIsComplete = TRUE; } #else - //First get the "ACK" lock, then do normal wait for signal, then release - // ACK lock, to let end-process know it can free the process struct - pthread_mutex_lock( &(process->doneAckLock) ); + //This is called from main thread, so must use OS thread constructs to + // force the main thread to block (suspend) until it is signalled that + // the process is complete. One issue is that the mutex and cond variable + // are inside the process data struct, which is freed when the process + // ends! pthread_mutex_lock( &(process->doneLock) ); while( process->executionIsComplete != TRUE ) { diff -r 7b6f8cf08b1f -r b02b34681414 PR__SS.c --- a/PR__SS.c Wed Jun 12 14:12:06 2013 -0700 +++ b/PR__SS.c Wed Jul 10 14:49:04 2013 -0700 @@ -363,10 +363,13 @@ // return. return; #else + //Here, must use OS thread constructs.. the main thread is waiting for + // PR process to complete. So, at this point, cause main to resume. + pthread_mutex_lock( &(process->doneLock) ); process->executionIsComplete = TRUE; + pthread_cond_broadcast( &(process->doneCond) ); pthread_mutex_unlock( &(process->doneLock) ); - pthread_cond_broadcast( &(process->doneCond) ); //now wait for woken waiter to Ack, then free the process struct pthread_mutex_lock( &(process->doneAckLock) ); //BUG:? may be a race pthread_mutex_unlock( &(process->doneAckLock) ); @@ -378,8 +381,8 @@ { pthread_mutex_lock( &(_PRTopEnv->activityDoneLock) ); _PRTopEnv->allActivityIsDone = TRUE; + pthread_cond_broadcast( &(_PRTopEnv->activityDoneCond) ); pthread_mutex_unlock( &(_PRTopEnv->activityDoneLock) ); - pthread_cond_broadcast( &(_PRTopEnv->activityDoneCond) ); } }