VMS/VMS_Implementations/VMS_impls/VMS__MC_shared_impl

changeset 286:b02b34681414 Dev_ML

VReo V2 -- saves checker and doer fn with the port, where triggered
author Sean Halle <seanhalle@yahoo.com>
date Wed, 10 Jul 2013 14:49:04 -0700
parents 7b6f8cf08b1f
children 744b5ff9851e
files PR.c PR__SS.c
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/PR.c	Wed Jun 12 14:12:06 2013 -0700
     1.2 +++ b/PR.c	Wed Jul 10 14:49:04 2013 -0700
     1.3 @@ -232,9 +232,11 @@
     1.4        process->executionIsComplete = TRUE;
     1.5      }
     1.6    #else
     1.7 -      //First get the "ACK" lock, then do normal wait for signal, then release
     1.8 -      // ACK lock, to let end-process know it can free the process struct
     1.9 -   pthread_mutex_lock( &(process->doneAckLock) );   
    1.10 +      //This is called from main thread, so must use OS thread constructs to
    1.11 +      // force the main thread to block (suspend) until it is signalled that
    1.12 +      // the process is complete.  One issue is that the mutex and cond variable
    1.13 +      // are inside the process data struct, which is freed when the process
    1.14 +      // ends!
    1.15     pthread_mutex_lock( &(process->doneLock) );
    1.16     while( process->executionIsComplete != TRUE )
    1.17      {
     2.1 --- a/PR__SS.c	Wed Jun 12 14:12:06 2013 -0700
     2.2 +++ b/PR__SS.c	Wed Jul 10 14:49:04 2013 -0700
     2.3 @@ -363,10 +363,13 @@
     2.4           // return.
     2.5        return;
     2.6       #else
     2.7 +      //Here, must use OS thread constructs.. the main thread is waiting for
     2.8 +      // PR process to complete.  So, at this point, cause main to resume.
     2.9 +       
    2.10        pthread_mutex_lock(     &(process->doneLock) );
    2.11        process->executionIsComplete = TRUE;
    2.12 +      pthread_cond_broadcast( &(process->doneCond) );
    2.13        pthread_mutex_unlock(   &(process->doneLock) );
    2.14 -      pthread_cond_broadcast( &(process->doneCond) );
    2.15           //now wait for woken waiter to Ack, then free the process struct
    2.16        pthread_mutex_lock(     &(process->doneAckLock)  ); //BUG:? may be a race
    2.17        pthread_mutex_unlock(   &(process->doneAckLock)  );  
    2.18 @@ -378,8 +381,8 @@
    2.19      { 
    2.20        pthread_mutex_lock(     &(_PRTopEnv->activityDoneLock) );
    2.21        _PRTopEnv->allActivityIsDone = TRUE;
    2.22 +      pthread_cond_broadcast( &(_PRTopEnv->activityDoneCond) );
    2.23        pthread_mutex_unlock(   &(_PRTopEnv->activityDoneLock) );
    2.24 -      pthread_cond_broadcast( &(_PRTopEnv->activityDoneCond) );
    2.25      }
    2.26   }
    2.27