changeset 272:bc5030385120 Dev_ML

Progress -- back to compile process, fixing compile issues
author Sean Halle <seanhalle@yahoo.com>
date Tue, 05 Feb 2013 20:23:27 -0800
parents 292393c6bef1
children 40e7625e57bd
files AnimationMaster.c CoreController.c PR.h PR__PI.c PR__PI.h PR__SS.c PR__WL.h PR__int.c PR__int.h PR__structs.h Services_Offered_by_PR/Services_Language/PRServ.h Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c
diffstat 13 files changed, 537 insertions(+), 552 deletions(-) [+]
line diff
     1.1 --- a/AnimationMaster.c	Wed Jan 16 01:50:26 2013 -0800
     1.2 +++ b/AnimationMaster.c	Tue Feb 05 20:23:27 2013 -0800
     1.3 @@ -19,79 +19,37 @@
     1.4  void        PRHandle_Dissipate_SL(SlaveVP *slave);
     1.5  void        PR_int__handle_PRServiceReq_SL(SlaveVP *slave);
     1.6  */
     1.7 -inline void PRHandle_CreateTask( PRReqst *req, SlaveVP *slave );
     1.8 -inline void PRHandle_EndTask(    PRReqst *req, SlaveVP *slave );
     1.9 -inline void PRHandle_CreateSlave(PRReqst *req, SlaveVP *slave );
    1.10 -void        PRHandle_EndSlave(  PRReqst *req, SlaveVP *slave );
    1.11 +inline void PRHandle__CreateTask( PRReqst *req, SlaveVP *slave );
    1.12 +inline void PRHandle__EndTask(    PRReqst *req, SlaveVP *slave );
    1.13 +inline void PRHandle__CreateSlave(PRReqst *req, SlaveVP *slave );
    1.14 +void        PRHandle__EndSlave(  PRReqst *req, SlaveVP *slave );
    1.15  
    1.16  
    1.17  //inline void  masterFunction_SingleLang( PRLangEnv *protoLangEnv, AnimSlot *slot );
    1.18  inline PRProcess * pickAProcess( AnimSlot *slot );
    1.19  inline bool32 assignWork( PRProcess *process, AnimSlot *slot );
    1.20  
    1.21 -/*The animationMaster embodies most of the animator of the language.  The
    1.22 - * animator is what emodies the behavior of language constructs. 
    1.23 - * As such, it is the animationMaster, in combination with the plugin
    1.24 - * functions, that make the language constructs do their behavior.   
    1.25 - * 
    1.26 - *Within the code, this is the top-level-function of the masterVPs, and
    1.27 - * runs when the coreController has no more slave VPs.  It's job is to
    1.28 - * refill the animation slots with slaves that have work.
    1.29 - *
    1.30 - *There are multiple versions of the master, each tuned to a specific 
    1.31 - * combination of modes.  This keeps the master simple, with reduced overhead,
    1.32 - * when the application is not using the extra complexity.
    1.33 - * 
    1.34 - *As of Sept 2012, the versions available will be:
    1.35 - * 1) Single langauge, which only exposes slaves (such as SSR or Vthread)
    1.36 - * 2) Single language, which only exposes tasks  (such as pure dataflow)
    1.37 - * 3) Single language, which exposes both (like Cilk, StarSs, and OpenMP)
    1.38 - * 4) Multi-language, which always assumes both tasks and slaves
    1.39 - * 5) Multi-language and multi-process, which also assumes both tasks and slaves
    1.40 - *
    1.41 - * 
    1.42 - *
    1.43 +
    1.44 +/*Note: there used to be a coreController that was another animation 
    1.45 + * layer below both the masterVP and the slaveVPs.. in that case, the
    1.46 + * masterVP was a virtual processor whose processor-state was the same
    1.47 + * as a slaveVP's processor sate, both implemented as a SlaveVP struct.
    1.48 + * Have removed that, and
    1.49 + * changed the masterVP implementation.  Instead of being a special  version 
    1.50 + * of a proto-runtime virtual processor, using the slaveVP stuct, the 
    1.51 + * Master "virtual processor" is now implemented as a pthread pinned to
    1.52 + * a physical core.
    1.53   */
    1.54  
    1.55 -//This version of the master selects one of three loops, depending upon
    1.56 -// whether stand-alone single language (just slaves), or standalone with
    1.57 -// tasks, or multi-lang (implies multi-process)
    1.58 -void animationMaster( void *_environment, SlaveVP *masterVP )
    1.59 - { 
    1.60 -   TopEnv         *masterEnv = (TopEnv *)_environment;
    1.61 -   int32           slotIdx;
    1.62 -   AnimSlot       *currSlot;
    1.63 -      //Used while scanning and filling animation slots
    1.64 -   AnimSlot      **animSlots;
    1.65 -   
    1.66 -      //Local copies, for performance
    1.67 -   int32           thisCoresIdx;
    1.68 -   
    1.69 -   //======================== Initializations ========================
    1.70 -   thisCoresIdx     = masterVP->coreAnimatedBy;
    1.71 -   animSlots        = masterEnv->allAnimSlots[thisCoresIdx];
    1.72 -      
    1.73 -      HOLISTIC__Insert_Master_Global_Vars;
    1.74 -   
    1.75 -   //======================== animationMaster ========================
    1.76 -   //Have three different modes, and the master behavior is different for
    1.77 -   // each, so jump to the loop that corresponds to the mode.
    1.78 -   //
    1.79 -   while(1)
    1.80 -    {       MEAS__Capture_Pre_Master_Point
    1.81 -      for( slotIdx = 0; slotIdx < NUM_ANIM_SLOTS; slotIdx++)
    1.82 -       {
    1.83 -         currSlot = animSlots[ slotIdx ];
    1.84 -
    1.85 -         masterFunction( currSlot );
    1.86 -       }
    1.87 -            MEAS__Capture_Post_Master_Point;
    1.88 -      masterSwitchToCoreCtlr( masterVP ); //returns when ctlr switches back to master
    1.89 -      flushRegisters();
    1.90 -    }
    1.91 - }
    1.92 -
    1.93 -
    1.94 +/*This is the behavior of the Master.  The physical processor switches
    1.95 + * between animating the master, and animating a slave.  When a slave
    1.96 + * suspends, the PR "suspend" primitive switches the physical core over
    1.97 + * to animating the masterVP, which is implemented as a pinned pthread.
    1.98 + * This function is the behavior of that masterVP.
    1.99 + *This function's job is to manage processing
   1.100 + * requests and to trigger assignment of new work to the physical core,
   1.101 + * and to manage sharing the core among processes.
   1.102 + */
   1.103  inline
   1.104  bool32
   1.105  masterFunction( AnimSlot  *slot )
   1.106 @@ -104,6 +62,8 @@
   1.107     bool32          foundWork;
   1.108  
   1.109        //Check if newly-done slave in slot, which will need request handled
   1.110 +      //NOTE: left over from when had a coreController & MasterVP managed
   1.111 +      // several slots
   1.112     if( slot->workIsDone )
   1.113      { slot->workIsDone = FALSE;
   1.114        slot->needsWorkAssigned = TRUE;
   1.115 @@ -126,16 +86,16 @@
   1.116         { case TaskEnd: 
   1.117            { //do PR handler, which calls lang's hdlr and does recycle of
   1.118              // free task slave if needed -- PR handler checks for free task Slv
   1.119 -            PRHandle_EndTask( req, slave );                          break;
   1.120 +            PRHandle__EndTask( req, slave );                          break;
   1.121            }
   1.122           case TaskCreate:
   1.123            { //Do PR's create-task handler, which calls the lang's hdlr
   1.124              // PR handler checks for free task Slv
   1.125 -            PRHandle_CreateTask( req, slave );                       break;
   1.126 +            PRHandle__CreateTask( req, slave );                       break;
   1.127            }
   1.128 -         case SlvCreate:    PRHandle_CreateSlave( req, slave );      break;
   1.129 -         case SlvDissipate: PRHandle_EndSlave( req, slave );         break;
   1.130 -         case Service:      PR_int__handle_PRServiceReq( slave );    break; //resumes into Service lang env
   1.131 +         case SlvCreate:    PRHandle__CreateSlave( req, slave );      break;
   1.132 +         case SlvDissipate: PRHandle__EndSlave( req, slave );         break;
   1.133 +         case Service:      PRHandle__ServiceReq( slave );    break; //resumes into Service lang env
   1.134           case Hardware: //for future expansion
   1.135           case IO:       //for future expansion
   1.136           case OSCall:   //for future expansion
   1.137 @@ -151,10 +111,12 @@
   1.138             HOLISTIC__Record_AppResponder_end;
   1.139      } //if have request to be handled
   1.140  
   1.141 -   if( slot->needsWorkAssigned )
   1.142 +      //NOTE: IF statement is leftover from when master managed many slots
   1.143 +   foundWork = FALSE;
   1.144 +   if( slot->needsWorkAssigned ) //can probably remove IF, not that only one slot
   1.145      {
   1.146              HOLISTIC__Record_Assigner_start;
   1.147 -
   1.148 +      
   1.149           //Pick a process to get this slot
   1.150        process = pickAProcess( slot );
   1.151  
   1.152 @@ -164,6 +126,8 @@
   1.153        assignWork( process, slot );
   1.154  
   1.155              HOLISTIC__Record_Assigner_end;
   1.156 +
   1.157 +//      fixme; //make this a while loop that tries a different process if this one fails
   1.158      }//if slot needs slave assigned
   1.159     
   1.160     return foundWork;
   1.161 @@ -223,9 +187,7 @@
   1.162  inline 
   1.163  bool32
   1.164  assignWork( PRProcess *process, AnimSlot *slot )
   1.165 - { SlaveVP        *returnSlv;
   1.166 -   int32           coreNum, slotNum;
   1.167 -   PRMetaTask     *assignedMetaTask;
   1.168 + { int32           coreNum;
   1.169  
   1.170     coreNum = slot->coreSlotIsOn;
   1.171     
   1.172 @@ -244,9 +206,21 @@
   1.173     numEnvs = process->numLangEnvs;
   1.174     for( envIdx = 0; envIdx < numEnvs; envIdx++ ) //keep langEnvs in hash & array
   1.175      { langEnv = langEnvsList[envIdx];
   1.176 -      if( langEnv->hasWork )
   1.177 -       { (*langEnv->workAssigner)( langEnv, slot ); //assigner calls PR to put slave/task into slot
   1.178 -         goto ReturnAfterAssigningWork; //quit for-loop, cause found work
   1.179 +      if( langEnv->numReadyWork > 0 )
   1.180 +       { bool32 
   1.181 +         didAssignWork =
   1.182 +          (*langEnv->workAssigner)( langEnv, slot ); //assigner calls PR to put slave/task into slot
   1.183 +
   1.184 +         if(didAssignWork)
   1.185 +          { langEnv->numReadyWork -= 1;
   1.186 +            if( langEnv->numReadyWork == 0 )
   1.187 +             { process->numEnvsWithWork -= 1;
   1.188 +             }
   1.189 +            goto ReturnAfterAssigningWork; //quit for-loop, 'cause found work
   1.190 +          }
   1.191 +         else
   1.192 +            goto NoWork; //quit for-loop, cause found work
   1.193 +       
   1.194           //NOTE: bad search alg -- should start where left off, then wrap around
   1.195         }
   1.196      }
   1.197 @@ -255,7 +229,7 @@
   1.198   NoWork:     //No work, if end up here..
   1.199      { 
   1.200     #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
   1.201 -      returnSlv = process->idleSlv[coreNum][slotNum]; 
   1.202 +      returnSlv = process->idleSlv[coreNum][0];  //only one slot now, so [0]
   1.203      
   1.204           //things that would normally happen in resume(), but idle VPs
   1.205           // never go there
   1.206 @@ -313,24 +287,25 @@
   1.207   */
   1.208  inline
   1.209  void
   1.210 -PRHandle_CreateSlave( PRReqst *req, SlaveVP *slave )
   1.211 +PRHandle__CreateSlave( PRReqst *req, SlaveVP *slave )
   1.212   { SlaveVP   *newSlv;
   1.213     PRProcess *process;
   1.214     PRLangEnv *protoLangEnv;
   1.215   
   1.216     process = slave->processSlaveIsIn;
   1.217     protoLangEnv = PR_int__give_proto_lang_env_for_slave__ML( slave, req->langMagicNumber );
   1.218 -   
   1.219 -//   newSlv  = PR_int__create_slave( req->topLevelFn, req->initData );
   1.220 -   
   1.221 -   //create slv has diff prototype than standard reqst hdlr
   1.222 +      
   1.223 +   //create handler, or a future request handler will call PR_PI__make_slave_ready
   1.224 +   // which will in turn handle updating which langlets and which processes have
   1.225 +   // work available.
   1.226 +   //NOTE: create slv has diff prototype than standard reqst hdlr
   1.227     newSlv = 
   1.228        (*req->createHdlr)(req->langReq, slave, PR_int__give_lang_env(protoLangEnv)); 
   1.229     
   1.230     newSlv->typeOfVP = GenericSlv;
   1.231     newSlv->processSlaveIsIn = process;
   1.232     newSlv->ID = req->ID;
   1.233 -   process->numLiveGenericSlvs += 1;
   1.234 +   process->numLiveGenericSlvs += 1; //not same as work ready!
   1.235   }
   1.236  
   1.237  /*The dissipate handler has to, update the number of slaves of the type, within
   1.238 @@ -345,7 +320,7 @@
   1.239   */
   1.240  inline
   1.241  void
   1.242 -PRHandle_EndSlave( PRReqst *req, SlaveVP *slave )
   1.243 +PRHandle__EndSlave( PRReqst *req, SlaveVP *slave )
   1.244   { PRProcess *process;
   1.245     PRLangEnv *protoLangEnv;
   1.246     
   1.247 @@ -357,13 +332,14 @@
   1.248     if(req->handler != NULL)
   1.249        (*req->handler)( req->langReq, slave, PR_int__give_lang_env(protoLangEnv) );
   1.250     
   1.251 -   process->numLiveGenericSlvs -= 1;
   1.252 -   PR_int__recycle_slave__ML( slave );
   1.253 -  
   1.254 +   process->numLiveGenericSlvs -= 1; 
   1.255 +   PR_int__recycle_slave( slave );
   1.256 +   //NOTE: dissipate is unrelated to work available (just in case wondering)
   1.257 +
   1.258        //check End Of Process Condition
   1.259     if( process->numLiveTasks == 0 &&
   1.260         process->numLiveGenericSlvs == 0 )
   1.261 -      PR_SS__shutdown_process__ML( process );
   1.262 +      PR_SS__shutdown_process( process );
   1.263   }
   1.264  
   1.265  /*Create task is a special form, that has PR behavior in addition to plugin
   1.266 @@ -374,7 +350,7 @@
   1.267   */
   1.268  inline
   1.269  void
   1.270 -PRHandle_CreateTask( PRReqst *req, SlaveVP *slave )
   1.271 +PRHandle__CreateTask( PRReqst *req, SlaveVP *slave )
   1.272   { PRMetaTask     *metaTask;
   1.273     PRProcess      *process;
   1.274     PRLangEnv      *protoLangEnv;
   1.275 @@ -400,8 +376,8 @@
   1.276     return;
   1.277   }
   1.278  
   1.279 -/*When a task ends, are two scenarios: 1) task ran to completion, or 2) task
   1.280 - * suspended at some point in its code.
   1.281 +/*When a task ends, have two scenarios: 1) task ran to completion, or 2) task
   1.282 + * has been suspended at some point in its code.
   1.283   *For 1, just decr count of live tasks (and check for end condition) -- the
   1.284   * master loop will decide what goes into the slot freed up by this task end,
   1.285   * so, here, don't worry about assigning a new task to the slot slave.
   1.286 @@ -425,13 +401,13 @@
   1.287   */
   1.288  inline 
   1.289  void
   1.290 -PRHandle_EndTask( PRReqst *req, SlaveVP *requestingSlv )
   1.291 +PRHandle__EndTask( PRReqst *req, SlaveVP *requestingSlv )
   1.292   { void       *langEnv;
   1.293     PRProcess  *process;
   1.294     void       *langMetaTask;
   1.295     
   1.296 -   langEnv = PR_int__give_lang_env_of_req__ML( req, requestingSlv ); //magic num in req
   1.297 -   langMetaTask = PR_int__give_lang_meta_task_from_slave__ML( requestingSlv, req->langMagicNumber);
   1.298 +   langEnv = PR_int__give_lang_env_of_req( req, requestingSlv ); //magic num in req
   1.299 +   langMetaTask = PR_int__give_lang_meta_task_from_slave( requestingSlv, req->langMagicNumber);
   1.300     
   1.301     //Do the langlet's request handler
   1.302     //Want to keep PR structs hidden from plugin, so extract langReq..
   1.303 @@ -439,15 +415,47 @@
   1.304     
   1.305     //Now that the langlet's done with it, recycle the slave if it's a freeTaskSlv
   1.306     if( requestingSlv->typeOfVP == FreeTaskSlv )
   1.307 -      PR_int__recycle_slave__ML( requestingSlv );
   1.308 +      PR_int__recycle_slave( requestingSlv ); //Doesn't decr num live slaves
   1.309     
   1.310     process->numLiveTasks -= 1;
   1.311 +   //NOTE: end-task is unrelated to work available (just in case wondering)
   1.312    
   1.313        //check End Of Process Condition
   1.314     if( process->numLiveTasks == 0 &&
   1.315         process->numLiveGenericSlvs == 0 )
   1.316      { //Tell the core controller to do wakeup of any waiting OS thread
   1.317 -      PR_SS__shutdown_process__ML( process );
   1.318 +      PR_SS__shutdown_process( process );
   1.319      }
   1.320   }
   1.321  
   1.322 +
   1.323 +/*This is for OS requests and PR infrastructure requests, which are not
   1.324 + * part of the PRServ language -- this is for things that have to be in the
   1.325 + * infrastructure of PR itself, such as I/O requests, which have to go through
   1.326 + * pthreads inside the core controller..
   1.327 + * 
   1.328 + *As of Jan 2013, doesn't do much of anything..
   1.329 + */
   1.330 +void inline
   1.331 +PRHandle__ServiceReq( SlaveVP *requestingSlv )
   1.332 + { PRReqst   *req;
   1.333 +   PRServReq *langReq;
   1.334 +   void      *langEnv;
   1.335 +   int32      magicNumber;
   1.336 +   
   1.337 + 
   1.338 +   req = requestingSlv->request;
   1.339 + 
   1.340 +   magicNumber = req->langMagicNumber;
   1.341 +   langEnv = PR_PI__give_lang_env_for( slave, magicNumber );
   1.342 +
   1.343 +   langReq = PR_PI__take_lang_reqst_from(req);
   1.344 +   if( langReq == NULL ) return;
   1.345 +   switch( langReq->reqType )  //lang handlers are all in other file
   1.346 +    {
   1.347 +      case make_probe:      handleMakeProbe(   langReq, langEnv );
   1.348 +         break;
   1.349 +      case throw_excp:  handleThrowException(  langReq, langEnv );
   1.350 +         break;
   1.351 +    }
   1.352 + }
     2.1 --- a/CoreController.c	Wed Jan 16 01:50:26 2013 -0800
     2.2 +++ b/CoreController.c	Tue Feb 05 20:23:27 2013 -0800
     2.3 @@ -90,7 +90,7 @@
     2.4     thisCoresThdParams = (ThdParams *)paramsIn;
     2.5     thisCoresIdx = thisCoresThdParams->coreNum;
     2.6  
     2.7 -      //Assembly that saves addr of label of return instr -- label in assmbly
     2.8 +      //Assembly that saves addr of label of return instr -- addr used in assmbly
     2.9     recordCoreCtlrReturnLabelAddr((void**)&(_PRTopEnv->coreCtlrReturnPt));
    2.10  
    2.11     //TODO: DEBUG: check get correct pointer here
     3.1 --- a/PR.h	Wed Jan 16 01:50:26 2013 -0800
     3.2 +++ b/PR.h	Tue Feb 05 20:23:27 2013 -0800
     3.3 @@ -91,8 +91,8 @@
     3.4  
     3.5  
     3.6  //========================= Services =======================
     3.7 -//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
     3.8 -//#include  "Services_Offered_by_PR/Services_Language/PRServ.h"
     3.9 +#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
    3.10 +#include "Services_Offered_by_PR/Services_Language/PRServ.h"
    3.11  //#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
    3.12  
    3.13  //================================================
     4.1 --- a/PR__PI.c	Wed Jan 16 01:50:26 2013 -0800
     4.2 +++ b/PR__PI.c	Tue Feb 05 20:23:27 2013 -0800
     4.3 @@ -23,6 +23,54 @@
     4.4   */
     4.5  
     4.6  
     4.7 +/*All langlets use this call to make their slaves ready..  this, in turn,
     4.8 + * calls the make_ready that was registered by the langlet.
     4.9 + */
    4.10 +void
    4.11 +PR_PI__make_slave_ready( SlaveVP *slave, void *_langEnv )
    4.12 + { PRLangEnv *protoLangEnv;
    4.13 + 
    4.14 +   if( _PRTopEnv->overrideAssigner != NULL )
    4.15 +    {
    4.16 +      //put slave into override readyQ
    4.17 +      
    4.18 +      //update override hasWork flag ?
    4.19 +    }
    4.20 +   else
    4.21 +    { //call langlet's registered make ready
    4.22 +      protoLangEnv = PR_int__give_proto_lang_env( _langEnv );
    4.23 +      (*protoLangEnv->makeSlaveReadyFn)( slave, _langEnv );
    4.24 +      
    4.25 +      //incr amount of work ready, in langlet's environ
    4.26 +      protoLangEnv->numReadyWork += 1;
    4.27 +      if(protoLangEnv->numReadyWork == 1)
    4.28 +       { protoLangEnv->processEnvIsIn->numEnvsWithWork += 1;
    4.29 +       }
    4.30 +    }
    4.31 + }
    4.32 +
    4.33 +void
    4.34 +PR_PI__make_task_ready( void *_task, void *_langEnv )
    4.35 + { PRLangEnv *protoLangEnv;
    4.36 + 
    4.37 +   if( _PRTopEnv->overrideAssigner != NULL )
    4.38 +    {
    4.39 +      //put task into override readyQ
    4.40 +      
    4.41 +      //update override hasWork flag ?
    4.42 +    }
    4.43 +   else
    4.44 +    { //call langlet's registered make ready
    4.45 +      protoLangEnv = PR_int__give_proto_lang_env( _langEnv );
    4.46 +      (*protoLangEnv->makeTaskReadyFn)( _task, _langEnv );
    4.47 +      
    4.48 +      //incr amount of work ready, in langlet's environ
    4.49 +      protoLangEnv->numReadyWork += 1;
    4.50 +      if(protoLangEnv->numReadyWork == 1)
    4.51 +       { protoLangEnv->processEnvIsIn->numEnvsWithWork += 1;
    4.52 +       }
    4.53 +    }
    4.54 + }
    4.55  
    4.56   
    4.57  PRReqst *
     5.1 --- a/PR__PI.h	Wed Jan 16 01:50:26 2013 -0800
     5.2 +++ b/PR__PI.h	Tue Feb 05 20:23:27 2013 -0800
     5.3 @@ -36,9 +36,11 @@
     5.4   * wrapper-library calls!
     5.5   */
     5.6  
     5.7 +#define PR_PI__create_slaveVP PR_int__create_slaveVP_helper
     5.8 +
     5.9  inline
    5.10  SlaveVP *
    5.11 -PR_PI__give_slave_lang_meta_task_assigned_to( void *langMetaTask );
    5.12 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
    5.13  
    5.14  
    5.15  PRReqst *
     6.1 --- a/PR__SS.c	Wed Jan 16 01:50:26 2013 -0800
     6.2 +++ b/PR__SS.c	Tue Feb 05 20:23:27 2013 -0800
     6.3 @@ -126,7 +126,7 @@
     6.4     process->numLangEnvs  = 0;
     6.5     
     6.6        //A Process starts with one slave, the seed slave
     6.7 -   seedSlv = PR_int__create_slaveVP__ML( seed_Fn, seedData, process );
     6.8 +   seedSlv = PR_int__create_slaveVP( seed_Fn, seedData, process );
     6.9     seedSlv->typeOfVP           = SeedSlv;
    6.10     seedSlv->processSlaveIsIn   = process;
    6.11     process->numLiveGenericSlvs = 1; //count the  seed
    6.12 @@ -188,12 +188,12 @@
    6.13   * 
    6.14   */
    6.15  PRProcess *
    6.16 -PR__create_process__ML( TopLevelFnPtr seed_Fn, void *seedData )
    6.17 +PR__create_process( TopLevelFnPtr seed_Fn, void *seedData )
    6.18   { SlaveVP    *seedSlv;
    6.19     PRProcess  *process;
    6.20     PRLangEnv **langEnvs, **langEnvsList;
    6.21     
    6.22 -   _PRTopEnv->mode         = MultiLang;
    6.23 +   _PRTopEnv->mode         = MultiLang; //leftover, not used, but reminder
    6.24     
    6.25        //This runs outside of the master lock, so use PR_WL form of malloc
    6.26     process = PR_WL__malloc( sizeof(PRProcess) );
    6.27 @@ -208,7 +208,7 @@
    6.28     process->numLangEnvs  = 0;
    6.29     
    6.30        //A Process starts with one slave, the seed slave
    6.31 -   seedSlv = PR_int__create_slaveVP__ML( seed_Fn, seedData, process );
    6.32 +   seedSlv = PR_int__create_slaveVP( seed_Fn, seedData, process );
    6.33     seedSlv->typeOfVP           = SeedSlv;
    6.34     seedSlv->processSlaveIsIn   = process;
    6.35     process->numLiveGenericSlvs = 1; //count the  seed 
    6.36 @@ -249,7 +249,7 @@
    6.37      #endif
    6.38      }
    6.39     pthread_mutex_init( &(process->doneLock), NULL );
    6.40 -   pthread_cond_init( &(process->doneCond), NULL );
    6.41 +   pthread_cond_init(  &(process->doneCond), NULL );
    6.42     process->executionIsComplete = FALSE;
    6.43     
    6.44     return process;
    6.45 @@ -259,7 +259,7 @@
    6.46  /*are already in Master when detect, inside end-task or dissipate, so call "PR_SS__shutdown_process"
    6.47   */
    6.48  void
    6.49 -PR_SS__shutdown_process__ML( PRProcess *process )
    6.50 +PR_SS__shutdown_process( PRProcess *process )
    6.51   { int32 i, processIdx;
    6.52     PRProcess **processes;
    6.53     
    6.54 @@ -317,20 +317,19 @@
    6.55     process->executionIsComplete = TRUE;
    6.56     pthread_mutex_unlock(   &(process->doneLock) );
    6.57     pthread_cond_broadcast( &(process->doneCond) );
    6.58 -      //BUG: process struct can be freed and re-allocated  before waiter sees
    6.59 -      // executionIsComplete
    6.60 +      //now wait for woken waiter to Ack, then free the process struct
    6.61 +   pthread_mutex_lock(     &(process->doneAckLock)  ); //BUG:? may be a race
    6.62 +   pthread_mutex_unlock(   &(process->doneAckLock)  );  
    6.63 +   PR_int__free(process);
    6.64  
    6.65 -      //if last process, cause resume of "PR__wait_for_all_activity_to_end"
    6.66 -   if( _PRTopEnv->numProcesses == 1 )
    6.67 -    { implement_me(); //have to ensure that PRServ has no activity -- do later
    6.68 +      //if no more processes, cause resume of "PR__wait_for_all_activity_to_end"
    6.69 +   if( _PRTopEnv->numProcesses == 0)
    6.70 +    { 
    6.71        pthread_mutex_lock(     &(_PRTopEnv->activityDoneLock) );
    6.72        _PRTopEnv->allActivityIsDone = TRUE;
    6.73        pthread_mutex_unlock(   &(_PRTopEnv->activityDoneLock) );
    6.74        pthread_cond_broadcast( &(_PRTopEnv->activityDoneCond) );
    6.75      }
    6.76 -
    6.77 -      //lastly, free the PRProcess struct itself
    6.78 -   PR_int__free(process);
    6.79   }
    6.80  
    6.81  /*This waits for the OS threads in the PR system to end.  Causing them to end
    6.82 @@ -359,16 +358,25 @@
    6.83     pthread_mutex_unlock( &(_PRTopEnv->activityDoneLock) );
    6.84   }
    6.85  
    6.86 +
    6.87  void
    6.88 -PR__wait_for_process_to_end()
    6.89 - { 
    6.90 -   pthread_mutex_lock( &(_PRTopEnv->activityDoneLock) );
    6.91 -   while( !(_PRTopEnv->allActivityIsDone) )
    6.92 +PR__wait_for_process_to_end( PRProcess *process )
    6.93 + {    //First get the "ACK" lock, then do normal wait for signal, then release
    6.94 +      // ACK lock, to let end-process know it can free the process struct
    6.95 +   pthread_mutex_lock( &(process->doneAckLock) );   
    6.96 +   pthread_mutex_lock( &(process->doneLock) );
    6.97 +   while( process->executionIsComplete != TRUE )
    6.98      {
    6.99 -      pthread_cond_wait( &(_PRTopEnv->activityDoneCond),
   6.100 -                         &(_PRTopEnv->activityDoneLock) );
   6.101 +      pthread_cond_wait( &(process->doneCond),
   6.102 +                         &(process->doneLock) );
   6.103      }
   6.104 -   pthread_mutex_unlock( &(_PRTopEnv->activityDoneLock) );
   6.105 +   pthread_mutex_unlock( &(process->doneLock) );
   6.106 +      //now send "ACK" signal to process_end Fn, that it may proceed
   6.107 +   pthread_mutex_unlock( &(process->doneAckLock) ); 
   6.108 +   
   6.109 +      //TODO: BUG? -- can process be created and end, before this acquires the
   6.110 +      // first lock?  Can see some rare code that creates a bunch, before getting
   6.111 +      // to waiting..  leave for now..  pain to fix..
   6.112   }
   6.113  
   6.114  /*When all work in the process has completed, then return from this call.
   6.115 @@ -386,17 +394,26 @@
   6.116  void *
   6.117  PR__give_results_from_process_when_ready( PRProcess *process )
   6.118   { void *result;
   6.119 +      //First get the "ACK" lock, then do normal wait for signal, then release
   6.120 +      // ACK lock, to let end-process know it can free the process struct
   6.121 +   pthread_mutex_lock( &(process->doneAckLock) );
   6.122     
   6.123     pthread_mutex_lock( &(process->doneLock) );
   6.124 -   while( !(process->executionIsComplete) )
   6.125 +   while( process->executionIsComplete != TRUE )
   6.126      {
   6.127        pthread_cond_wait( &(process->doneCond),
   6.128                           &(process->doneLock) );
   6.129      }
   6.130 +   pthread_mutex_unlock( &(process->doneLock) );
   6.131     result = process->resultToReturn;
   6.132 -   pthread_mutex_unlock( &(process->doneLock) );
   6.133 +   
   6.134 +      //now send "ACK" signal to process_end Fn, that it may proceed
   6.135 +   pthread_mutex_unlock( &(process->doneAckLock) ); 
   6.136        
   6.137     return result;
   6.138 +      //TODO: BUG? -- can process be created and end, before this acquires the
   6.139 +      // first lock?  Can see some rare code that creates a bunch, before getting
   6.140 +      // to waiting..  leave for now..  pain to fix..
   6.141   }
   6.142  
   6.143  
   6.144 @@ -412,6 +429,54 @@
   6.145   * found by using magic num to look it up in the process that the seedVP
   6.146   * is inside of.
   6.147   */
   6.148 +void
   6.149 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum )
   6.150 + { PRLangEnv *langEnv;
   6.151 + 
   6.152 +   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.153 +   langEnv->workAssigner = assigner; 
   6.154 + }
   6.155 +void
   6.156 +PR_SS__register_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP,
   6.157 +                                  int32 magicNum )
   6.158 + { PRLangEnv *langEnv;
   6.159 + 
   6.160 +   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.161 +   langEnv->shutdownHdlr = shutdownHdlr; 
   6.162 + }
   6.163 +void
   6.164 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 
   6.165 +                                              SlaveVP *seedVP, int32 magicNum )
   6.166 + { PRLangEnv *langEnv;
   6.167 + 
   6.168 +   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.169 +   langEnv->langDataCreator = langDataCreator; 
   6.170 + }
   6.171 +void
   6.172 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 
   6.173 +                                              SlaveVP *seedVP, int32 magicNum )
   6.174 + { PRLangEnv *langEnv;
   6.175 + 
   6.176 +   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.177 +   langEnv->langMetaTaskCreator = langMetaTaskCreator; 
   6.178 + }
   6.179 +void
   6.180 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP,
   6.181 +                                                         int32 magicNum )
   6.182 + { PRLangEnv *langEnv;
   6.183 + 
   6.184 +   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.185 +   langEnv->makeSlaveReadyFn = fn; 
   6.186 + }
   6.187 +void
   6.188 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP,
   6.189 +                                                         int32 magicNum )
   6.190 + { PRLangEnv *langEnv;
   6.191 + 
   6.192 +   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.193 +   langEnv->makeTaskReadyFn = fn; 
   6.194 + }
   6.195 +
   6.196  /*
   6.197  void
   6.198  PR_SS__register_create_task_handler( RequestHandler createTaskHandler, SlaveVP *seedVP, int32 magicNum )
   6.199 @@ -449,31 +514,8 @@
   6.200     langEnv->requestHdlr = reqHandler; 
   6.201   }
   6.202   */
   6.203 -void
   6.204 -PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum )
   6.205 - { PRLangEnv *langEnv;
   6.206 - 
   6.207 -   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.208 -   langEnv->workAssigner = assigner; 
   6.209 - }
   6.210 -void
   6.211 -PR_SS__register_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP,
   6.212 -                                  int32 magicNum )
   6.213 - { PRLangEnv *langEnv;
   6.214 - 
   6.215 -   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.216 -   langEnv->shutdownHdlr = shutdownHdlr; 
   6.217 - }
   6.218  /*
   6.219  void
   6.220 -PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 
   6.221 -                                              SlaveVP *seedVP, int32 magicNum )
   6.222 - { PRLangEnv *langEnv;
   6.223 - 
   6.224 -   langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.225 -   langEnv->langDataCreator = langDataCreator; 
   6.226 - }
   6.227 -void
   6.228  PR_SS__register_lang_data_initializer( LangDataInitializer langDataInitializer, 
   6.229                                                SlaveVP *seedVP, int32 magicNum )
   6.230   { PRLangEnv *langEnv;
   6.231 @@ -481,7 +523,6 @@
   6.232     langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.233     langEnv->langDataInitializer = langDataInitializer; 
   6.234   }
   6.235 -*/
   6.236  void
   6.237  PR_SS__register_lang_data_freer( LangDataFreer langDataFreer, 
   6.238                                                SlaveVP *seedVP, int32 magicNum )
   6.239 @@ -490,6 +531,7 @@
   6.240     langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum );
   6.241     langEnv->langDataFreer = langDataFreer; 
   6.242   }
   6.243 +*/
   6.244  
   6.245  
   6.246  
   6.247 @@ -604,7 +646,7 @@
   6.248        readyToAnimateQs[ coreIdx ] = makePRQ();
   6.249        
   6.250           //Q: should give masterVP core-specific info as its init data?
   6.251 -      masterVPs[ coreIdx ] = PR_int__create_slave( (TopLevelFnPtr)&animationMaster, (void*)_PRTopEnv );
   6.252 +      masterVPs[ coreIdx ] = PR_int__create_slaveVP_helper( (TopLevelFnPtr)&animationMaster, (void*)_PRTopEnv );
   6.253        masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
   6.254        masterVPs[ coreIdx ]->typeOfVP = Master;
   6.255        allAnimSlots[ coreIdx ] = create_anim_slots( coreIdx ); //makes for one core
   6.256 @@ -619,7 +661,7 @@
   6.257      { //langEnv->coreIsDone[coreNum] = FALSE; //use during shutdown
   6.258      
   6.259        for( slotNum = 0; slotNum < NUM_ANIM_SLOTS; ++slotNum )
   6.260 -       { idleSlv = PR_int__create_slaveVP( &idle_fn, NULL );
   6.261 +       { idleSlv = PR_int__create_slaveVP_helper( &idle_fn, NULL );
   6.262           idleSlv->coreAnimatedBy                = coreNum;
   6.263           idleSlv->animSlotAssignedTo            =
   6.264                                 _PRTopEnv->allAnimSlots[coreNum][slotNum];
   6.265 @@ -666,7 +708,7 @@
   6.266     _PRTopEnv->numProcesses = 0;
   6.267     _PRTopEnv->currProcessIdx = 0;
   6.268     _PRTopEnv->firstProcessReady = FALSE;      //use while starting up coreCtlr   
   6.269 -   
   6.270 +      
   6.271        //initialize flags for waiting for activity within PR to complete
   6.272     pthread_mutex_init( &(_PRTopEnv->activityDoneLock), NULL );
   6.273     pthread_cond_init(  &(_PRTopEnv->activityDoneCond), NULL );
   6.274 @@ -825,7 +867,7 @@
   6.275   {
   6.276     SlaveVP* shutdownVP;
   6.277     
   6.278 -   shutdownVP = PR_int__create_slave( &endOSThreadFn, NULL );
   6.279 +   shutdownVP = PR_int__create_slaveVP_helper( &endOSThreadFn, NULL );
   6.280     shutdownVP->typeOfVP = Shutdown;
   6.281      
   6.282     return shutdownVP;
     7.1 --- a/PR__WL.h	Wed Jan 16 01:50:26 2013 -0800
     7.2 +++ b/PR__WL.h	Tue Feb 05 20:23:27 2013 -0800
     7.3 @@ -57,7 +57,10 @@
     7.4  
     7.5  inline
     7.6  SlaveVP *
     7.7 -PR_PI__give_slave_lang_meta_task_assigned_to( void *langMetaTask );
     7.8 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
     7.9 +
    7.10 +
    7.11 +#define PR_WL__create_slaveVP PR_int__create_slaveVP_helper
    7.12  
    7.13  //==============  Request Related  ===============
    7.14  
     8.1 --- a/PR__int.c	Wed Jan 16 01:50:26 2013 -0800
     8.2 +++ b/PR__int.c	Tue Feb 05 20:23:27 2013 -0800
     8.3 @@ -25,9 +25,12 @@
     8.4  //===========================================================================
     8.5  //
     8.6  //===========================================================================
     8.7 +/*This does the basic work of creating the SlaveVP structure.. but doesn't
     8.8 + * know which process it goes in, nor what type of VP it is, etc..
     8.9 + */
    8.10  inline
    8.11  SlaveVP *
    8.12 -PR_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam )
    8.13 +PR_int__create_slaveVP_helper( TopLevelFnPtr fnPtr, void *dataParam )
    8.14   { SlaveVP *newSlv;
    8.15     void    *stackLocs;
    8.16     
    8.17 @@ -43,8 +46,8 @@
    8.18        
    8.19     newSlv->numTimesAssignedToASlot  = 0;  
    8.20  
    8.21 -   newSlv->langData = NULL;
    8.22 -   newSlv->metaTask     = NULL;
    8.23 +   newSlv->langDatas = NULL;
    8.24 +   newSlv->metaTasks     = NULL;
    8.25  
    8.26     PR_int__reset_slaveVP_to_TopLvlFn( newSlv, fnPtr, dataParam );
    8.27     
    8.28 @@ -65,49 +68,49 @@
    8.29  
    8.30  inline
    8.31  SlaveVP *
    8.32 -PR_int__create_slaveVP__ML( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process )
    8.33 +PR_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process )
    8.34   { SlaveVP *newSlv;
    8.35   
    8.36 -   newSlv = PR_int__create_slaveVP( fnPtr, dataParam );
    8.37 +   newSlv = PR_int__create_slaveVP_helper( fnPtr, dataParam );
    8.38        
    8.39     int32 *
    8.40     langDatas    = PR_int__malloc( sizeof(int32) + NUM_IN_COLLECTION * sizeof(PRLangData *) );
    8.41     langDatas[0] = NUM_IN_COLLECTION;    //size held in prolog
    8.42 -   newSlv->langData = &(langDatas[1]); //skip over the size
    8.43 +   newSlv->langDatas = &(langDatas[1]); //skip over the size
    8.44             
    8.45     int32 *
    8.46     metaTasks    = PR_int__malloc( sizeof(int32) + NUM_IN_COLLECTION * sizeof(PRMetaTask *) );
    8.47     metaTasks[0] = NUM_IN_COLLECTION;    //size held in prolog
    8.48 -   newSlv->metaTask = &(metaTasks[1]);
    8.49 +   newSlv->metaTasks = &(metaTasks[1]);
    8.50     
    8.51     process->numLiveGenericSlvs += 1;
    8.52   }
    8.53  
    8.54  
    8.55 -/*
    8.56 +/*A slot slave doesn't use array for lang data nor meta tasks, but it's in
    8.57 + * there anyway..  have to copy what create slave does, so can just change 
    8.58 + * the type when a slot slave is converted..
    8.59   */
    8.60 -/*
    8.61 -inline
    8.62  SlaveVP *
    8.63 -PR_int__create_seed_slave__ML( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process )
    8.64 - { SlaveVP *newSlv;
    8.65 +PR_int__create_slot_slave( )
    8.66 + { SlaveVP *retSlv;
    8.67   
    8.68 -   newSlv = PR_int__create_slaveVP( fnPtr, dataParam );
    8.69 -      
    8.70 +   retSlv = PR_int__create_slaveVP_helper( &idle_fn, NULL );
    8.71 +   retSlv->typeOfVP     = SlotTaskSlv; 
    8.72 +   
    8.73     int32 *
    8.74     langDatas    = PR_int__malloc( sizeof(int32) + NUM_IN_COLLECTION * sizeof(PRLangData *) );
    8.75 -   langDatas[0] = NUM_IN_COLLECTION;       //size held in prolog
    8.76 -   newSlv->langData = &(langDatas[1]); //skip over the size
    8.77 +   langDatas[0] = NUM_IN_COLLECTION;    //size held in prolog
    8.78 +   retSlv->langDatas = &(langDatas[1]); //skip over the size
    8.79             
    8.80     int32 *
    8.81     metaTasks    = PR_int__malloc( sizeof(int32) + NUM_IN_COLLECTION * sizeof(PRMetaTask *) );
    8.82     metaTasks[0] = NUM_IN_COLLECTION;    //size held in prolog
    8.83 -   newSlv->metaTask = &(metaTasks[1]);  //make slave point to array
    8.84 +   retSlv->metaTasks = &(metaTasks[1]);
    8.85     
    8.86 -   newSlv->typeOfVP            = SeedSlv;
    8.87 -   process->numLiveGenericSlvs = 1;
    8.88 +   return retSlv;
    8.89   }
    8.90 -*/
    8.91 +
    8.92  
    8.93  
    8.94  /*Called when a new slot slave is needed..  takes from recycle pool, and 
    8.95 @@ -130,26 +133,12 @@
    8.96        retSlv->request      = NULL;
    8.97      }
    8.98     else //if none to recycle, create a new one
    8.99 -    { retSlv = PR_int__create_slaveVP_helper( &idle_fn, NULL );
   8.100 -      retSlv->typeOfVP     = SlotTaskSlv; 
   8.101 +    { retSlv = PR_int__create_slot_slave();
   8.102      }
   8.103     
   8.104     return retSlv;
   8.105   }
   8.106  
   8.107 -/*A slot slave has no array for lang data nor meta tasks -- it only ever has
   8.108 - * one meta task..
   8.109 - */
   8.110 -SlaveVP *
   8.111 -PR_int__create_slot_slave( )
   8.112 - { SlaveVP *retSlv;
   8.113 - 
   8.114 -    retSlv = PR_int__create_slaveVP_helper( &idle_fn, NULL );
   8.115 -    retSlv->typeOfVP     = SlotTaskSlv; 
   8.116 -   
   8.117 -   return retSlv;
   8.118 - }
   8.119 -
   8.120  //==========================================================================
   8.121  /*When a task in a slot slave suspends, the slot slave has to be changed to
   8.122   * a free task slave, then the slot slave replaced.  The replacement can be
   8.123 @@ -178,18 +167,7 @@
   8.124        //Fix up requester, to be an extra slave now (but not an ended one)
   8.125        // because it's active, doesn't go into freeTaskSlvRecycleQ
   8.126     requestingSlv->typeOfVP = FreeTaskSlv;
   8.127 -   requestingSlv->processSlaveIsIn = process;
   8.128 -   
   8.129 -   
   8.130 -   int32 *
   8.131 -   langDatas    = PR_int__malloc( sizeof(int32) + NUM_IN_COLLECTION * sizeof(PRLangData *) );
   8.132 -   langDatas[0] = NUM_IN_COLLECTION;    //size held in prolog
   8.133 -   newSlotSlv->langData = &(langDatas[1]); //skip over the size
   8.134 -           
   8.135 -   int32 *
   8.136 -   metaTasks    = PR_int__malloc( sizeof(int32) + NUM_IN_COLLECTION * sizeof(PRMetaTask *) );
   8.137 -   metaTasks[0] = NUM_IN_COLLECTION;    //size held in prolog
   8.138 -   newSlotSlv->metaTask = &(metaTasks[1]);
   8.139 +   requestingSlv->processSlaveIsIn = process;   
   8.140   }
   8.141  
   8.142  void idle_fn(void* data, SlaveVP *animatingSlv)
   8.143 @@ -201,37 +179,6 @@
   8.144  
   8.145  
   8.146  
   8.147 -/* This is for OS requests and PR infrastructure requests, such as to create
   8.148 - *  a probe -- a probe is inside the heart of PR-core, it's not part of any
   8.149 - *  language -- but it's also a semantic thing that's triggered from and used
   8.150 - *  in the application.. so it crosses abstractions..  so, need some special
   8.151 - *  pattern here for handling such requests.
   8.152 - * Doing this just like it were a second language sharing PR-core.
   8.153 - */
   8.154 -void inline
   8.155 -PR_int__handle_PRServiceReq( SlaveVP *requestingSlv )
   8.156 - { PRReqst   *req;
   8.157 -   PRServReq *langReq;
   8.158 -   void      *langEnv;
   8.159 -   int32      magicNumber;
   8.160 -   
   8.161 - 
   8.162 -   req = requestingSlv->request;
   8.163 - 
   8.164 -   magicNumber = req->langMagicNumber;
   8.165 -   langEnv = PR_PI__give_lang_env_for( slave, magicNumber );
   8.166 -
   8.167 -   langReq = PR_PI__take_lang_reqst_from(req);
   8.168 -   if( langReq == NULL ) return;
   8.169 -   switch( langReq->reqType )  //lang handlers are all in other file
   8.170 -    {
   8.171 -      case make_probe:      handleMakeProbe(   langReq, langEnv );
   8.172 -         break;
   8.173 -      case throw_excp:  handleThrowException(  langReq, langEnv );
   8.174 -         break;
   8.175 -    }
   8.176 - }
   8.177 -
   8.178  //===========================================================================
   8.179  /*there is a label inside this function -- save the addr of this label in
   8.180   * the callingSlv struc, as the pick-up point from which to start the next
   8.181 @@ -271,63 +218,25 @@
   8.182  
   8.183  
   8.184  
   8.185 -/*This must be called by the request handler plugin -- it cannot be called
   8.186 - * from the semantic library "dissipate processor" function -- instead, the
   8.187 - * semantic layer has to generate a request, and the plug-in calls this
   8.188 - * function.
   8.189 - *The reason is that this frees the virtual processor's stack -- which is
   8.190 - * still in use inside semantic library calls!
   8.191 - *
   8.192 - *This frees or recycles all the state owned by and comprising the PR
   8.193 - * portion of the animating virtual procr.  The request handler must first
   8.194 - * free any semantic data created for the processor that didn't use the
   8.195 - * PR_malloc mechanism.  Then it calls this, which first asks the malloc
   8.196 - * system to disown any state that did use PR_malloc, and then frees the
   8.197 - * statck and the processor-struct itself.
   8.198 - *If the dissipated processor is the sole (remaining) owner of PR_int__malloc'd
   8.199 - * state, then that state gets freed (or sent to recycling) as a side-effect
   8.200 - * of dis-owning it.
   8.201 - */
   8.202 -void
   8.203 -PR_int__dissipate_slaveVP__SL( SlaveVP *animatingSlv )
   8.204 - {
   8.205 -         DEBUG__printf2(dbgRqstHdlr, "PR int dissipate slaveNum: %d, alive: %d",animatingSlv->slaveNum, _PRTopEnv->numSlavesAlive-1);
   8.206 -      //dis-own all locations owned by this processor, causing to be freed
   8.207 -      // any locations that it is (was) sole owner of
   8.208 -   _PRTopEnv->numSlavesAlive -= 1;
   8.209 -   if( _PRTopEnv->numSlavesAlive == 0 )
   8.210 -    {    //no more work, so shutdown
   8.211 -      PR_SS__shutdown();  //note, creates shut-down processor on each core
   8.212 -    }
   8.213 -
   8.214 -      //NOTE: dataParam was given to the processor, so should either have
   8.215 -      // been alloc'd with PR_int__malloc, or freed by the level above animSlv.
   8.216 -      //So, all that's left to free here is the stack and the SlaveVP struc
   8.217 -      // itself
   8.218 -      //Note, should not stack-allocate initial data -- no guarantee, in
   8.219 -      // general that creating processor will outlive ones it creates.
   8.220 -   PR_int__free( animatingSlv->startOfStack );
   8.221 -   PR_int__free( animatingSlv );
   8.222 - }
   8.223 -
   8.224 -
   8.225  /*In multi-lang mode, there are multiple langData in the slave..  
   8.226   * 
   8.227   *At some point want to recycle rather than free..
   8.228   * 
   8.229   *For now, iterate through langData, call registered free-er on each, then
   8.230   * free the basic slave
   8.231 + * 
   8.232 + *DOES NOT DECREMENT NUMBER OF LIVE SLAVES IN PROCESS
   8.233   */
   8.234  void
   8.235 -PR_int__free_slaveVP__ML( SlaveVP *slave )
   8.236 +PR_int__free_slaveVP( SlaveVP *slave )
   8.237   {       
   8.238 -   PR_int__apply_Fn_to_all_in_collection( &recycleLangDataAsElem, 
   8.239 -                                           (PRCollElem**) slave->langData );
   8.240 -   PR_int__apply_Fn_to_all_in_collection( &recycleMetaTaskAsElem, 
   8.241 -                                           (PRCollElem**) slave->metaTask );
   8.242 +   PR_int__apply_Fn_to_all_in_collection( &freeLangDataAsElem, 
   8.243 +                                           (PRCollElem**) slave->langDatas );
   8.244 +   PR_int__apply_Fn_to_all_in_collection( &freeMetaTaskAsElem, 
   8.245 +                                           (PRCollElem**) slave->metaTasks );
   8.246     
   8.247 -   PR_int__free( &(((int32*)(slave->langData))[-1]) );
   8.248 -   PR_int__free( &(((int32*)(slave->metaTask))[-1]) );
   8.249 +   PR_int__free( &(((int32*)(slave->langDatas))[-1]) );
   8.250 +   PR_int__free( &(((int32*)(slave->metaTasks))[-1]) );
   8.251     PR_int__free( slave->startOfStack );
   8.252     PR_int__free( slave );   
   8.253   }
   8.254 @@ -335,39 +244,49 @@
   8.255  /*This calls recycle handler registered for each langlet's lang data and meta
   8.256   * task.  It also recycles the slave struct.
   8.257   * 
   8.258 + *DOES NOT DECREMENT NUMBER OF LIVE SLAVES IN PROCESS
   8.259 + * 
   8.260   *This assumes that each slave has an array of 
   8.261   */
   8.262  void
   8.263 -PR_int__recycle_slave__ML( SlaveVP *slave )
   8.264 +PR_int__recycle_slave( SlaveVP *slave )
   8.265   { 
   8.266 -   PR_int__apply_Fn_to_all_in_collection( &recycleLangDataAsElem, 
   8.267 -                                           (PRCollElem**) slave->langData );
   8.268 -   PR_int__apply_Fn_to_all_in_collection( &recycleMetaTaskAsElem, 
   8.269 -                                           (PRCollElem**) slave->metaTask );
   8.270 +   PR_int__apply_Fn_to_all_in_collection( &freeLangDataAsElem, 
   8.271 +                                           (PRCollElem**) slave->langDatas );
   8.272 +   PR_int__apply_Fn_to_all_in_collection( &freeMetaTaskAsElem, 
   8.273 +                                           (PRCollElem**) slave->metaTasks );
   8.274  
   8.275     writePrivQ( slave, _PRTopEnv->slaveRecycleQ );
   8.276   }
   8.277  
   8.278 +/*Receives a protoLangData, but in the form of a void, so have to cast
   8.279 + */
   8.280  void
   8.281 -recycleLangDataAsElem( void *elem )
   8.282 - { PRLangData *langData;
   8.283 +freeLangDataAsElem( void *elem )
   8.284 + { PRLangData *protoLangData;
   8.285     
   8.286 -   langData = (PRLangData *)elem; //recycler receives the prolog, and must call
   8.287 +   protoLangData = (PRLangData *)elem; //recycler actually receives the prolog.
   8.288 +   
   8.289 +      //apply the free fn that's stored in the lang data prolog
   8.290 +      //Note: freeing whole slave, so no need to remove from collection
   8.291 +      //Note: langlet's freer only frees what langlet has malloc'd
   8.292 +   if(protoLangData->freer != NULL)
   8.293 +    { (*(protoLangData->freer))( PR_int__give_lang_data_of_prolog(protoLangData) );
   8.294 +    }
   8.295 +   PR_int__free( protoLangData );
   8.296 + }
   8.297 +
   8.298 +/*Receives a protoMetaTask, but in form of a void, so have to cast
   8.299 + */
   8.300 +void
   8.301 +freeMetaTaskAsElem( void *elem )
   8.302 + { PRMetaTask *protoMetaTask;
   8.303 +   
   8.304 +   protoMetaTask = (PRMetaTask *)elem;  //recycler receives the prolog, and must call
   8.305     //a PR Fn to convert prolog to lang-specific version.
   8.306     
   8.307 -      //apply the recycle fn that's stored in the lang data prolog
   8.308 -   (*(langData->recycler))(langData); //lang registered the recycler    
   8.309 - }
   8.310 -
   8.311 -void
   8.312 -recycleMetaTaskAsElem( void *elem )
   8.313 - { PRMetaTask *metaTask;
   8.314 -   
   8.315 -   metaTask = (PRMetaTask *)elem;  //recycler receives the prolog, and must call
   8.316 -   //a PR Fn to convert prolog to lang-specific version.
   8.317 -   
   8.318 -      //apply the recycle fn that's stored in the lang data prolog
   8.319 -   (*(metaTask->recycler))(metaTask); //lang registered the recycler    
   8.320 +      //apply the free fn that's stored in the meta task prolog
   8.321 +   (*(protoMetaTask->freer))( PR_int__give_lang_meta_task_of_prolog(protoMetaTask) );  
   8.322   }
   8.323  
   8.324  
   8.325 @@ -427,7 +346,7 @@
   8.326  
   8.327  inline
   8.328  void *
   8.329 -PR_int__give_lang_env_of_req__ML( PRReqst *req, SlaveVP *requestingSlv )
   8.330 +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv )
   8.331   {     
   8.332     return PR_int__give_lang_env_from_process( requestingSlv->processSlaveIsIn, 
   8.333                                                           req->langMagicNumber );
   8.334 @@ -435,13 +354,13 @@
   8.335  
   8.336  inline
   8.337  void *
   8.338 -PR_int__give_lang_env_for_slave__ML( SlaveVP *slave, int32 magicNum )
   8.339 +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum )
   8.340   {    
   8.341     return PR_int__give_lang_env_from_process( slave->processSlaveIsIn, magicNum );
   8.342   }
   8.343  inline
   8.344  PRLangEnv *
   8.345 -PR_int__give_proto_lang_env_for_slave__ML( SlaveVP *slave, int32 magicNum )
   8.346 +PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNum )
   8.347   {    
   8.348     return PR_int__give_proto_lang_env_for_process( slave->processSlaveIsIn, magicNum );
   8.349   }
   8.350 @@ -470,6 +389,7 @@
   8.351     return retLangEnv; //return prolog
   8.352   }
   8.353  
   8.354 +/*
   8.355  inline
   8.356  void
   8.357  PR_int__set_work_in_lang_env( void *_langEnv )
   8.358 @@ -489,7 +409,8 @@
   8.359        prototLangEnv->processEnvIsIn->numEnvsWithWork -= 1;
   8.360      }
   8.361   }
   8.362 -
   8.363 + */
   8.364 +  
   8.365  /*This is to be called by langlet's assigner.
   8.366   */
   8.367  inline
   8.368 @@ -543,7 +464,7 @@
   8.369  
   8.370       //point slave to task's function
   8.371     PR_int__reset_slaveVP_to_TopLvlFn( slotSlv, task->topLevelFn, task->initData );
   8.372 -   PR_int__insert_meta_task_into_slave__ML( task, slotSlv );
   8.373 +   PR_int__insert_meta_task_into_slave( task, slotSlv );
   8.374     PR_int__put_slave_into_slot( slotSlv, slot );
   8.375   }
   8.376  
   8.377 @@ -564,8 +485,8 @@
   8.378  
   8.379  
   8.380  inline
   8.381 -void *
   8.382 -PR_int__create_lang_meta_task__ML( int32 size, int32 magicNum )
   8.383 +PRMetaTask *
   8.384 +PR_int__create_proto_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum )
   8.385   { PRMetaTask *retMetaTask;
   8.386  
   8.387        //make the new meta task
   8.388 @@ -573,82 +494,132 @@
   8.389     retMetaTask->chainedMetaTask = NULL;
   8.390     retMetaTask->langMagicNumber = magicNum;
   8.391     retMetaTask->slaveAssignedTo = NULL;
   8.392 -   retMetaTask->taskType        = SlotTask;
   8.393 +   retMetaTask->taskType        = SlotTask; //just common default
   8.394     retMetaTask->ID              = NULL;
   8.395 +   retMetaTask->freer           = freer;
   8.396 +     
   8.397 +   return retMetaTask; //skip over prolog
   8.398 + }
   8.399 +
   8.400 +/*Might never need this fn -- think the slave dissipator does this work
   8.401 + */
   8.402 +void
   8.403 +PR_int__free_lang_meta_task( void *langMetaTask)
   8.404 + { PRMetaTask *protoMetaTask;
   8.405 +   
   8.406 +   protoMetaTask = PR_int__give_prolog_of_task( langMetaTask );
   8.407 +   PR_int__remove_elem_from_collection( protoMetaTask->langMagicNumber,
   8.408 +                                    protoMetaTask->slaveAssignedTo->metaTasks );
   8.409 +
   8.410 +   (*protoMetaTask->freer)(langMetaTask);
   8.411 +   PR_int__free( protoMetaTask );   
   8.412 + }
   8.413 +
   8.414 +inline
   8.415 +void *
   8.416 +PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum )
   8.417 + { PRMetaTask *retMetaTask;
   8.418 +
   8.419 +      //make the new meta task
   8.420 +
   8.421 +   retMetaTask = PR_int__create_proto_meta_task( size, freer, magicNum );
   8.422       
   8.423     return &(retMetaTask[1]); //skip over prolog
   8.424   }
   8.425  
   8.426 +inline
   8.427 +void
   8.428 +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave )
   8.429 + { 
   8.430 +   task->slaveAssignedTo = slave;
   8.431 +   PR_int__insert_elem_into_collection( (PRCollElem *)task, 
   8.432 +                        (PRCollElem **)slave->metaTasks, task->langMagicNumber );
   8.433 + }
   8.434 +inline
   8.435 +void
   8.436 +PR_int__insert_lang_meta_task_into_slave( void *langMetaTask, SlaveVP *slave )
   8.437 + { PRMetaTask *metaTask = &(((PRMetaTask*)langMetaTask)[-1]);
   8.438 +   metaTask->slaveAssignedTo = slave;
   8.439 +   PR_int__insert_elem_into_collection( (PRCollElem *)metaTask, 
   8.440 +                    (PRCollElem **)slave->metaTasks, metaTask->langMagicNumber );
   8.441 + }
   8.442 +
   8.443  /*allocates space for a new lang-meta-task, and inserts it into the slave,
   8.444   * under the given magic number.
   8.445   */
   8.446  inline
   8.447  void *
   8.448 -PR_int__create_lang_meta_task_in_slave__ML( int32 size, SlaveVP *slave, int32 magicNum )
   8.449 +PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, SlaveVP *slave, int32 magicNum )
   8.450   { PRMetaTask *retMetaTask;
   8.451     PRCollElem **metaTasks;
   8.452  
   8.453        //make the new meta task
   8.454 -   retMetaTask = PR_int__malloc( sizeof(PRMetaTask) + size );
   8.455 -   retMetaTask->chainedMetaTask = NULL;
   8.456 -   retMetaTask->langMagicNumber = magicNum;
   8.457 +   retMetaTask = PR_int__create_proto_meta_task( size, freer, magicNum );
   8.458     retMetaTask->slaveAssignedTo = slave;
   8.459     retMetaTask->taskType        = GenericSlave;
   8.460 -   retMetaTask->ID              = NULL;
   8.461  
   8.462 -      //multilang has a "collection" of meta tasks inside the slave
   8.463 -   metaTasks = (PRCollElem **)slave->metaTask; 
   8.464 +      //have a "collection" of meta tasks inside the slave
   8.465 +   metaTasks = (PRCollElem **)slave->metaTasks; 
   8.466     PR_int__insert_elem_into_collection( (PRCollElem *)retMetaTask, 
   8.467                                                            metaTasks, magicNum );
   8.468     
   8.469     return &(retMetaTask[1]); //skip over prolog
   8.470   }
   8.471  
   8.472 +
   8.473 +
   8.474  inline
   8.475 -void
   8.476 -PR_int__insert_meta_task_into_slave__ML( PRMetaTask *task, SlaveVP *slave )
   8.477 - { 
   8.478 -   task->slaveAssignedTo = slave;
   8.479 -   PR_int__insert_elem_into_collection( (PRCollElem *)task, 
   8.480 -                        (PRCollElem **)slave->metaTask, task->langMagicNumber );
   8.481 +void *
   8.482 +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNum )
   8.483 + { PRMetaTask  *retMetaTask;
   8.484 +   PRCollElem **metaTasks;
   8.485 +   PRLangEnv   *protoLangEnv;
   8.486 +   
   8.487 +   metaTasks = (PRCollElem **)slave->metaTasks;
   8.488 +   retMetaTask = PR_int__lookup_elem_in_collection( magicNum, metaTasks );
   8.489 +   if( retMetaTask != NULL ) 
   8.490 +      return &(retMetaTask[1]); //skip over prolog
   8.491 +   else
   8.492 +    { protoLangEnv = PR_int__give_proto_lang_env_for_slave( slave );
   8.493 +      if(protoLangEnv->langMetaTaskCreator == NULL) 
   8.494 +         PR_int__throw_exception("register a meta task creator");
   8.495 +         //This will call 
   8.496 +      return (*protoLangEnv->langMetaTaskCreator)( slave );
   8.497 +    }
   8.498   }
   8.499 +
   8.500  inline
   8.501 -void
   8.502 -PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave )
   8.503 +SlaveVP *
   8.504 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask )
   8.505   { PRMetaTask *metaTask = &(((PRMetaTask*)langMetaTask)[-1]);
   8.506 -   metaTask->slaveAssignedTo = slave;
   8.507 -   PR_int__insert_elem_into_collection( (PRCollElem *)metaTask, 
   8.508 -                    (PRCollElem **)slave->metaTask, metaTask->langMagicNumber );
   8.509 +   return metaTask->slaveAssignedTo;
   8.510 + }
   8.511 +
   8.512 +//================== langData =============================
   8.513 +inline 
   8.514 +PRLangData *
   8.515 +PR_int__give_prolog_of_lang_data( void *langData )
   8.516 + {
   8.517 +    return (PRLangData *) &(((PRLangData *)langData)[-1]);
   8.518   }
   8.519  
   8.520  inline
   8.521  void *
   8.522 -PR_int__give_lang_meta_task_from_slave__ML( SlaveVP *slave, int32 magicNum )
   8.523 - { PRMetaTask  *retMetaTask;
   8.524 -   PRCollElem **metaTasks;
   8.525 -   
   8.526 -   metaTasks = (PRCollElem **)slave->metaTask;
   8.527 -   retMetaTask = PR_int__lookup_elem_in_collection( magicNum, metaTasks );
   8.528 -   if( retMetaTask != NULL ) 
   8.529 -      return &(retMetaTask[1]); //skip over prolog
   8.530 -   else
   8.531 -      return NULL;
   8.532 +PR_int__give_lang_data_of_prolog( PRLangData *langData)
   8.533 + {
   8.534 +   return (void *)&(langData[1]);
   8.535   }
   8.536  
   8.537 -inline
   8.538 -SlaveVP *
   8.539 -PR_PI__give_slave_lang_meta_task_assigned_to( void *langMetaTask )
   8.540 - { PRMetaTask *metaTask = &(((PRMetaTask*)langMetaTask)[-1]);
   8.541 -   return metaTask->slaveAssignedTo;
   8.542 - }
   8.543 -
   8.544 -//===============================================
   8.545 -/*Allocates space for a new lang-lang-data, and inserts it into the slave,
   8.546 +/*Allocates space for a new lang-data, and inserts it into the slave,
   8.547   * under the given magic number.  Also returns it.
   8.548 + * 
   8.549 + *Langlet is responsible for using this to create lang data inside its 
   8.550 + * create-slave handler
   8.551   */
   8.552  inline
   8.553  void *
   8.554 -PR_int__create_lang_data_in_slave__ML( int32 size, SlaveVP *slave, int32 magicNum )
   8.555 +PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, 
   8.556 +                                  SlaveVP *slave, int32 magicNum )
   8.557   { PRLangData   *retLangData;
   8.558     PRCollElem **langDatas;
   8.559  
   8.560 @@ -656,26 +627,45 @@
   8.561     retLangData = PR_int__malloc( sizeof(PRLangData) + size );
   8.562     retLangData->chainedLangData = NULL;
   8.563     retLangData->langMagicNumber = magicNum;
   8.564 +   retLangData->freer = freer;
   8.565 +   retLangData->slaveAssignedTo = slave;
   8.566    
   8.567        //multilang has a "collection" of lang datas inside the slave
   8.568 -   langDatas = (PRCollElem **)slave->langData; 
   8.569 +   langDatas = (PRCollElem **)slave->langDatas; 
   8.570     PR_int__insert_elem_into_collection( (PRCollElem *)retLangData, langDatas, magicNum );
   8.571     
   8.572     return &(retLangData[1]); //skip over prolog
   8.573   }
   8.574 +void
   8.575 +PR_int__free_lang_data( void *langData)
   8.576 + { PRLangData *protoLangData;
   8.577 +   
   8.578 +   protoLangData = PR_int__give_prolog_of_lang_data( langData );
   8.579 +   PR_int__remove_elem_from_collection( protoLangData->langMagicNumber,
   8.580 +                                    protoLangData->slaveAssignedTo->langDatas );
   8.581 +
   8.582 +   (*protoLangData->freer)(langData);
   8.583 +   PR_int__free( protoLangData );   
   8.584 + }
   8.585  
   8.586  inline
   8.587  void *
   8.588 -PR_int__give_lang_data_from_slave__ML( SlaveVP *slave, int32 magicNum )
   8.589 - { PRLangData   *retLangData;
   8.590 +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNum )
   8.591 + { PRLangData  *retLangData;
   8.592     PRCollElem **langDatas;
   8.593 +   PRLangEnv   *protoLangEnv;
   8.594     
   8.595 -   langDatas = (PRCollElem **)slave->langData;
   8.596 +   langDatas = (PRCollElem **)slave->langDatas;
   8.597     retLangData = PR_int__lookup_elem_in_collection( magicNum, langDatas );
   8.598     if( retLangData != NULL ) 
   8.599 -      return &(retLangData[1]); //skip over prolog
   8.600 +      return &( retLangData[1] ); //skip over prolog
   8.601     else
   8.602 -      return NULL;
   8.603 +    { protoLangEnv = PR_int__give_proto_lang_env_for_slave( slave );
   8.604 +      if(protoLangEnv->langDataCreator == NULL) 
   8.605 +         PR_int__throw_exception("register a lang data creator");
   8.606 +         //This will call PR_PI__create_lang_data_in_slave
   8.607 +      return (*protoLangEnv->langDataCreator)( slave );
   8.608 +    }
   8.609   }
   8.610  
   8.611  
     9.1 --- a/PR__int.h	Wed Jan 16 01:50:26 2013 -0800
     9.2 +++ b/PR__int.h	Tue Feb 05 20:23:27 2013 -0800
     9.3 @@ -19,17 +19,6 @@
     9.4   * int: internal to the PR implementation
     9.5   */
     9.6  
     9.7 -
     9.8 -inline SlaveVP *
     9.9 -PR_int__create_slave( TopLevelFnPtr fnPtr, void *dataParam );
    9.10 -#define PR_PI__create_slaveVP PR_int__create_slave
    9.11 -#define PR_WL__create_slaveVP PR_int__create_slave
    9.12 -
    9.13 -inline 
    9.14 -SlaveVP *
    9.15 -PR_int__create_slaveVP_helper( SlaveVP *newSlv,       TopLevelFnPtr  fnPtr,
    9.16 -                                void      *dataParam, void           *stackLocs );
    9.17 -
    9.18  inline
    9.19  PRMetaTask *
    9.20  PR_int__create_generic_slave_meta_task( void *initData );
    9.21 @@ -54,11 +43,11 @@
    9.22  //===========================================================================
    9.23  inline
    9.24  SlaveVP *
    9.25 -PR_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
    9.26 +PR_int__create_slaveVP_helper( TopLevelFnPtr fnPtr, void *dataParam );
    9.27  
    9.28  inline
    9.29  SlaveVP *
    9.30 -PR_int__create_slaveVP__ML( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process );
    9.31 +PR_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process );
    9.32  
    9.33  SlaveVP *
    9.34  PR_int__get_recycled_slot_slave( );
    9.35 @@ -82,7 +71,7 @@
    9.36  PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot );
    9.37  
    9.38  void inline
    9.39 -PR_int__handle_PRServiceReq(  SlaveVP *requestingSlv );
    9.40 +PRHandle__ServiceReq(  SlaveVP *requestingSlv );
    9.41  
    9.42  void
    9.43  PR_WL__suspend_slaveVP_and_send_req( SlaveVP *animatingSlv );
    9.44 @@ -91,16 +80,16 @@
    9.45  PR_int__dissipate_slaveVP__SL( SlaveVP *animatingSlv );
    9.46  
    9.47  void
    9.48 -PR_int__free_slaveVP__ML( SlaveVP *slave );
    9.49 +PR_int__free_slaveVP( SlaveVP *slave );
    9.50  
    9.51  void
    9.52 -PR_int__recycle_slave__ML( SlaveVP *slave );
    9.53 +PR_int__recycle_slave( SlaveVP *slave );
    9.54  
    9.55  void
    9.56 -recycleLangDataAsElem( void *elem );
    9.57 +freeLangDataAsElem( void *elem );
    9.58  
    9.59  void
    9.60 -recycleMetaTaskAsElem( void *elem );
    9.61 +freeMetaTaskAsElem( void *elem );
    9.62  
    9.63  inline 
    9.64  void *
    9.65 @@ -120,13 +109,13 @@
    9.66  
    9.67  inline
    9.68  void *
    9.69 -PR_int__give_lang_env_of_req__ML( PRReqst *req, SlaveVP *requestingSlv );
    9.70 +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv );
    9.71  
    9.72  inline
    9.73  void *
    9.74 -PR_int__give_lang_env_for_slave__ML( SlaveVP *slave, int32 magicNum );
    9.75 -#define PR_PI__give_lang_env_for  PR_int__give_lang_env_for_slave__ML
    9.76 -#define PR_SS__give_lang_env_for_slave  PR_int__give_lang_env_for_slave__ML
    9.77 +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum );
    9.78 +#define PR_PI__give_lang_env_for  PR_int__give_lang_env_for_slave
    9.79 +#define PR_SS__give_lang_env_for_slave  PR_int__give_lang_env_for_slave
    9.80  //No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
    9.81  
    9.82  inline
    9.83 @@ -148,6 +137,7 @@
    9.84  PRLangEnv *
    9.85  PR_int__give_proto_lang_env_for_process( PRProcess *process, int32 magicNum );
    9.86  
    9.87 +/*
    9.88  inline
    9.89  void
    9.90  PR_int__set_work_in_lang_env( void *_langEnv );
    9.91 @@ -155,6 +145,7 @@
    9.92  inline
    9.93  void
    9.94  PR_int__clear_work_in_lang_env( void *_langEnv );
    9.95 + */
    9.96  
    9.97  inline 
    9.98  PRMetaTask *
    9.99 @@ -166,15 +157,15 @@
   9.100  
   9.101  inline
   9.102  void *
   9.103 -PR_int__create_lang_meta_task__ML( int32 size, int32 magicNum );
   9.104 +PR_int__create_lang_meta_task( int32 size, int32 magicNum );
   9.105  
   9.106  inline
   9.107  void *
   9.108 -PR_int__create_lang_meta_task_in_slave__ML( int32 size, SlaveVP *slave, int32 magicNum );
   9.109 +PR_int__create_lang_meta_task_in_slave( int32 size, SlaveVP *slave, int32 magicNum );
   9.110  
   9.111  inline
   9.112  void
   9.113 -PR_int__insert_meta_task_into_slave__ML( PRMetaTask *task, SlaveVP *slave );
   9.114 +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave );
   9.115  
   9.116  inline
   9.117  void
   9.118 @@ -182,27 +173,27 @@
   9.119  
   9.120  inline
   9.121  void *
   9.122 -PR_int__give_lang_meta_task_from_slave__ML( SlaveVP *slave, int32 magicNumer );
   9.123 +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer );
   9.124  //#define PR_int__give_lang_meta_task_from_slave__ML( slave, magicNumber )\
   9.125          slave->metaTask->langMetaTask;
   9.126 -#define PR_PI__give_lang_meta_task_from_slave__ML  PR_int__give_lang_meta_task_from_slave__ML
   9.127 -#define PR_SS__give_lang_meta_task_from_slave__ML  PR_int__give_lang_meta_task_from_slave__ML
   9.128 -#define PR_WL__give_lang_meta_task_from_slave__ML  PR_int__give_lang_meta_task_from_slave__ML
   9.129 +#define PR_PI__give_lang_meta_task_from_slave__ML  PR_int__give_lang_meta_task_from_slave
   9.130 +#define PR_SS__give_lang_meta_task_from_slave__ML  PR_int__give_lang_meta_task_from_slave
   9.131 +#define PR_WL__give_lang_meta_task_from_slave__ML  PR_int__give_lang_meta_task_from_slave
   9.132  
   9.133  inline
   9.134  SlaveVP *
   9.135 -PR_PI__give_slave_lang_meta_task_assigned_to( void *langMetaTask );
   9.136 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
   9.137  
   9.138  inline
   9.139  void *
   9.140 -PR_int__create_lang_data_in_slave__ML( int32 size, SlaveVP *slave, int32 magicNum );
   9.141 +PR_PI__create_lang_data_in_slave( int32 size, SlaveVP *slave, int32 magicNum );
   9.142  
   9.143  inline
   9.144  void *
   9.145 -PR_int__give_lang_data_from_slave__ML( SlaveVP *slave, int32 magicNumer );
   9.146 -#define PR_PI__give_lang_data  PR_int__give_lang_data_from_slave__ML
   9.147 -#define PR_SS__give_lang_data  PR_int__give_lang_data_from_slave__ML
   9.148 -#define PR_WL__give_lang_data  PR_int__give_lang_data_from_slave__ML
   9.149 +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer );
   9.150 +#define PR_PI__give_lang_data  PR_int__give_lang_data_from_slave
   9.151 +#define PR_SS__give_lang_data  PR_int__give_lang_data_from_slave
   9.152 +#define PR_WL__give_lang_data  PR_int__give_lang_data_from_slave
   9.153  
   9.154  inline
   9.155  void
    10.1 --- a/PR__structs.h	Wed Jan 16 01:50:26 2013 -0800
    10.2 +++ b/PR__structs.h	Tue Feb 05 20:23:27 2013 -0800
    10.3 @@ -25,16 +25,21 @@
    10.4  typedef struct _SlaveVP       SlaveVP;
    10.5  typedef struct _MasterVP      MasterVP;
    10.6  typedef struct _IntervalProbe IntervalProbe;
    10.7 -typedef struct _PRLangEnv     PRLangEnv;   //a prolog
    10.8 +typedef struct _PRLangEnv     PRLangEnv;  //a prolog
    10.9  typedef struct _PRMetaTask    PRMetaTask; //a prolog
   10.10 -typedef struct _PRLangData    PRLangData;  //a prolog
   10.11 +typedef struct _PRLangData    PRLangData; //a prolog
   10.12  typedef struct _PRCollElem    PRCollElem; //generic form of the prologs
   10.13  
   10.14  typedef SlaveVP *(*SlaveAssigner)  ( void *, AnimSlot* ); //langEnv, slot for HW info
   10.15  typedef void     (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv
   10.16  typedef void    *(*CreateHandler)  ( void *, SlaveVP *, void * ); //req, slv, langEnv
   10.17 -typedef void     (*LangShutdownHdlr)( void * ); //langEnv
   10.18 -typedef void     (*LangDataFreer)  ( void * ); //lang data to free
   10.19 +typedef void     (*LangShutdownHdlr) ( void * ); //langEnv
   10.20 +typedef void    *(*LangDataCreator)  ( SlaveVP * ); 
   10.21 +typedef void     (*LangDataFreer)    ( void * ); //lang data to free
   10.22 +typedef void    *(*LangMetaTaskCreator)( SlaveVP * ); 
   10.23 +typedef void     (*LangMetaTaskFreer)  ( void * ); //lang meta task to free
   10.24 +typedef void     (*MakeSlaveReadyFn)   ( SlaveVP *, void * ); //slave and langEnv
   10.25 +typedef void     (*MakeTaskReadyFn)    ( void *, void * ); //langTask and langEnv
   10.26  typedef void     (*TopLevelFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
   10.27  typedef void       TopLevelFn      ( void *, SlaveVP * ); //initData, animSlv
   10.28  typedef void     (*ResumeSlvFnPtr) ( SlaveVP *, void * );
   10.29 @@ -84,6 +89,7 @@
   10.30     bool32          executionIsComplete;
   10.31     pthread_mutex_t doneLock;
   10.32     pthread_cond_t  doneCond;   
   10.33 +   pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting
   10.34  
   10.35        //=========== MEASUREMENT STUFF =============
   10.36         IntervalProbe   **intervalProbes;
   10.37 @@ -127,6 +133,8 @@
   10.38     void              *langReq;
   10.39     PRProcess         *processReqIsIn;
   10.40     int32              langMagicNumber;
   10.41 +   SlaveVP           *requestingSlave;
   10.42 +   
   10.43     TopLevelFnPtr      topLevelFn;
   10.44     void              *initData;
   10.45     int32             *ID;
   10.46 @@ -220,8 +228,8 @@
   10.47        //For language specific data that needs to be in the slave
   10.48        //These are accessed  directly for single-lang, but multi-lang places
   10.49        // a holder here instead, then uses magic num to get lang's version
   10.50 -   void       *langData;  //Lang saves lang-specific things in slave here
   10.51 -   void       *metaTask;
   10.52 +   void       *langDatas;  //Lang saves lang-specific things in slave here
   10.53 +   void       *metaTasks;
   10.54  
   10.55          //=========== MEASUREMENT STUFF ==========
   10.56           MEAS__Insert_Meas_Fields_into_Slave;
   10.57 @@ -250,7 +258,7 @@
   10.58        //============ below this, no fields are used in asm =============
   10.59  
   10.60        //Basic PR infrastructure
   10.61 -   enum PRMode      mode;
   10.62 +//   enum PRMode      mode;
   10.63     SlaveVP        **masterVPs;
   10.64     AnimSlot      ***allAnimSlots;
   10.65     PrivQueueStruc  *slaveRecycleQ;
   10.66 @@ -272,14 +280,13 @@
   10.67     int32            numProcesses;
   10.68     int32            currProcessIdx;    //used to choose which process gets slot
   10.69     int32            firstProcessReady; //use while starting up coreCtlr
   10.70 -   RequestHandler   free_lang_data;    //lang data persists after langlet stops
   10.71 -                                       //so need freer when end slaves
   10.72     
   10.73        //initialize flags for waiting for activity within PR to complete
   10.74 -   bool32          allActivityIsDone;
   10.75 -   pthread_mutex_t activityDoneLock;
   10.76 -   pthread_cond_t  activityDoneCond;   
   10.77 +   bool32           allActivityIsDone;
   10.78 +   pthread_mutex_t  activityDoneLock;
   10.79 +   pthread_cond_t   activityDoneCond;   
   10.80  
   10.81 +   SlaveAssigner    overrideAssigner;
   10.82     
   10.83     //============== Below this is only used by single-lang mode ==============
   10.84     void            *protoLangEnv;
   10.85 @@ -323,19 +330,21 @@
   10.86     //=============================================================
   10.87     
   10.88     SlaveAssigner    workAssigner;
   10.89 -//   RequestHandler  requestHdlr; 
   10.90     LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown
   10.91 -
   10.92 +   LangDataCreator  langDataCreator;
   10.93 +   LangMetaTaskCreator langMetaTaskCreator;
   10.94 +   MakeSlaveReadyFn makeSlaveReadyFn;
   10.95 +   MakeTaskReadyFn  makeTaskReadyFn;
   10.96  /*
   10.97     CreateTaskHdlr  createTaskHdlr;
   10.98     RequestHandler  endTaskHdlr; 
   10.99     CreateSlvHdlr   createSlaveHdlr;
  10.100     RequestHandler  dissipateSlaveHdlr;
  10.101    
  10.102 -   RequestHandler   langDataCreator;
  10.103 +   LangDataFreer    langDataFreer;
  10.104 +   LangMetaTaskFreer langMetaTaskFreer;
  10.105     RequestHandler   langDataInitializer;
  10.106   */
  10.107 -   LangDataFreer    langDataFreer;
  10.108       
  10.109        //when multi-lang, master polls lang env's to find one with work in it..
  10.110        // in single-lang case, flag ignored, master always asks lang for work
  10.111 @@ -343,6 +352,9 @@
  10.112     PRProcess      *processEnvIsIn;
  10.113     
  10.114     int32           idxInProcess; //index into array of langEnvs in the process
  10.115 +   
  10.116 +   int32           numReadyWork;
  10.117 +   fixme; //make make_ready update the process's numEnvs with work
  10.118   };
  10.119  //PRLangEnv -- this is the prolog of every lang's lang env
  10.120  
  10.121 @@ -362,7 +374,7 @@
  10.122     SlaveVP        *slaveAssignedTo; //no valid until task animated
  10.123     TopLevelFnPtr   topLevelFn;      //This is the Fn executes as the task
  10.124     void           *initData;        //The data taken by the function
  10.125 -   void          (*recycler)(void *);
  10.126 +   LangMetaTaskFreer freer;
  10.127  
  10.128     //NOTE: info needed for "wait" functionality is inside lang's metaTask
  10.129   };
  10.130 @@ -370,11 +382,11 @@
  10.131  
  10.132  struct _PRLangData
  10.133   { //============== First two must match PRCollElem ==============
  10.134 -   int32      langMagicNumber;
  10.135 -   PRLangData *chainedLangData;
  10.136 +   int32         langMagicNumber;
  10.137 +   PRLangData   *chainedLangData;
  10.138     //=============================================================
  10.139 -   void     (*recycler)(void *);
  10.140 -   void      *langLangData;
  10.141 +   LangDataFreer  freer;
  10.142 +   SlaveVP       *slaveAssignedTo;
  10.143   };
  10.144  //PRLangData -- this is the prolog of each lang's lang data
  10.145  
    11.1 --- a/Services_Offered_by_PR/Services_Language/PRServ.h	Wed Jan 16 01:50:26 2013 -0800
    11.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ.h	Tue Feb 05 20:23:27 2013 -0800
    11.3 @@ -6,13 +6,13 @@
    11.4   *
    11.5   */
    11.6  
    11.7 -#ifndef _PRServ_H
    11.8 -#define	_PRServ_H
    11.9  
   11.10  #include "Queue_impl/PrivateQueue.h"
   11.11  #include "Hash_impl/PrivateHash.h"
   11.12 -#include "PR_impl/PR.h"
   11.13 -#include "Measurement/dependency.h"
   11.14 +//#include "../Measurement_and_Stats/"
   11.15 +
   11.16 +#ifndef _PRServ_H
   11.17 +#define	_PRServ_H
   11.18  
   11.19  
   11.20  //===========================================================================
   11.21 @@ -45,35 +45,9 @@
   11.22   };
   11.23  
   11.24  
   11.25 -enum PRServReqType
   11.26 - {
   11.27 -   submit_task = 1,
   11.28 -   end_task,
   11.29 -   create_slave,
   11.30 -   create_slave_w_aff,
   11.31 -   dissipate_slave,
   11.32 -   //===============================
   11.33 -   send_type_to,
   11.34 -   receive_type_to,
   11.35 -   send_from_to,
   11.36 -   receive_from_to,
   11.37 -   //===============================
   11.38 -   taskwait,
   11.39 -   malloc_req,
   11.40 -   free_req,
   11.41 -   singleton_fn_start,
   11.42 -   singleton_fn_end,
   11.43 -   singleton_data_start,
   11.44 -   singleton_data_end,
   11.45 -   atomic,
   11.46 -   trans_start,
   11.47 -   trans_end
   11.48 - };
   11.49 -
   11.50  struct _PRServSemReq
   11.51   { enum PRServReqType    reqType;
   11.52     SlaveVP           *callingSlv;
   11.53 -   PRServTaskType       *taskType;
   11.54     void              *args;
   11.55  //   PRServTaskStub       *taskStub;  //not needed -- get via PR accessor from slv
   11.56     
   11.57 @@ -95,9 +69,7 @@
   11.58     void              *ptrToFree;
   11.59  
   11.60     int32              singletonID;
   11.61 -   PRServSingleton     **singletonPtrAddr;
   11.62  
   11.63 -   PtrToAtomicFn      fnToExecInMaster;
   11.64     void              *dataForFn;
   11.65  
   11.66     int32              transID;
   11.67 @@ -106,7 +78,7 @@
   11.68  
   11.69  
   11.70  typedef struct
   11.71 - { PRSemEnv        *protoSemEnv;
   11.72 + { PRLangEnv       *protoLangEnv;
   11.73     PrivQueueStruc  *slavesReadyToResumeQ; //Shared (slaves not pinned)
   11.74     PrivQueueStruc  *freeTaskSlvRecycleQ;    //Shared
   11.75     PrivQueueStruc  *taskReadyQ;           //Shared (tasks not pinned)
   11.76 @@ -116,8 +88,6 @@
   11.77     int32            primitiveStartTime;
   11.78  
   11.79                         //fix limit on num with dynArray
   11.80 -   PRServSingleton     fnSingletons[NUM_STRUCS_IN_SEM_ENV];
   11.81 -   PRServTrans         transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
   11.82     
   11.83     #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
   11.84     ListOfArrays* unitList;
   11.85 @@ -164,9 +134,6 @@
   11.86   
   11.87  //===========================================================================
   11.88  
   11.89 -void
   11.90 -PRServ__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
   11.91 -
   11.92  int32
   11.93  PRServ__giveMinWorkUnitCycles( float32 percentOverhead );
   11.94  
   11.95 @@ -191,13 +158,8 @@
   11.96  PRServ__cleanup_after_shutdown();
   11.97  
   11.98  //=======================
   11.99 -
  11.100 -SlaveVP *
  11.101 -PRServ__create_thread( TopLevelFnPtr fnPtr,   void *initData,
  11.102 -                                                     SlaveVP *creatingThd );
  11.103 -
  11.104  void
  11.105 -PRServ__end_thread( SlaveVP *thdToEnd );
  11.106 +PRServ__resume_slaveVP( SlaveVP *seedSlv, PRServLangEnv *servicesLangEnv );
  11.107  
  11.108  //=======================
  11.109  
  11.110 @@ -207,89 +169,16 @@
  11.111  
  11.112  
  11.113  //=======================
  11.114 -void
  11.115 -PRServ__submit_task( PRServTaskType *taskType, void *args, SlaveVP *animSlv);
  11.116 -
  11.117 -inline int32 *
  11.118 -PRServ__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
  11.119 -
  11.120 -void
  11.121 -PRServ__submit_task_with_ID( PRServTaskType *taskType, void *args, int32 *taskID, 
  11.122 -                          SlaveVP     *animSlv);
  11.123 -
  11.124 -void
  11.125 -PRServ__end_task( SlaveVP *animSlv );
  11.126  
  11.127  //=========================
  11.128 -void
  11.129 -PRServ__taskwait(SlaveVP *animSlv);
  11.130 -
  11.131 -
  11.132 -inline int32 *
  11.133 -PRServ__give_self_taskID( SlaveVP *animSlv );
  11.134 -
  11.135 -void
  11.136 -PRServ__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
  11.137 -                      SlaveVP *senderSlv );
  11.138 -
  11.139 -void
  11.140 -PRServ__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
  11.141 -
  11.142 -void *
  11.143 -PRServ__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
  11.144 -
  11.145 -void *
  11.146 -PRServ__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
  11.147 -
  11.148 -//======================= Concurrency Stuff ======================
  11.149 -void
  11.150 -PRServ__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
  11.151 -
  11.152 -void
  11.153 -PRServ__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
  11.154 -
  11.155 -void
  11.156 -PRServ__start_data_singleton( PRServSingleton **singeltonAddr, SlaveVP *animSlv );
  11.157 -
  11.158 -void
  11.159 -PRServ__end_data_singleton( PRServSingleton **singletonAddr, SlaveVP *animSlv );
  11.160 -
  11.161 -void
  11.162 -PRServ__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
  11.163 -                                    void *data, SlaveVP *animSlv );
  11.164 -
  11.165 -void
  11.166 -PRServ__start_transaction( int32 transactionID, SlaveVP *animSlv );
  11.167 -
  11.168 -void
  11.169 -PRServ__end_transaction( int32 transactionID, SlaveVP *animSlv );
  11.170  
  11.171  
  11.172  //=========================  Internal use only  =============================
  11.173 -void
  11.174 -PRServ__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
  11.175  
  11.176  SlaveVP *
  11.177  PRServ__assign_work_to_slot( void *_semEnv, AnimSlot *slot );
  11.178  
  11.179 -SlaveVP*
  11.180 -PRServ__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
  11.181 -                          PRServSemEnv *semEnv,    int32 coreToAssignOnto );
  11.182 -
  11.183 -PRMetaTask *
  11.184 -PR_int__create_generic_slave_meta_task( void *initData );
  11.185 -
  11.186 -
  11.187 -SlaveVP *
  11.188 -PRServ__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
  11.189 -                          SlaveVP *creatingSlv );
  11.190 -
  11.191 -SlaveVP *
  11.192 -PRServ__create_slave_with_affinity( TopLevelFnPtr fnPtr,    void *initData,
  11.193 -                            SlaveVP *creatingSlv, int32 coreToAssignOnto);
  11.194 -
  11.195  //=====================  Measurement of Lang Overheads  =====================
  11.196 -#include "Measurement/PRServ_Measurement.h"
  11.197  
  11.198  //===========================================================================
  11.199  #endif	/* _PRServ_H */
    12.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c	Wed Jan 16 01:50:26 2013 -0800
    12.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c	Tue Feb 05 20:23:27 2013 -0800
    12.3 @@ -67,7 +67,7 @@
    12.4     returnSlv = readPrivQ( semEnv->slavesReadyToResumeQ );
    12.5     if( returnSlv != NULL )  //Yes, have a slave, so return it.
    12.6      { returnSlv->coreAnimatedBy   = coreNum;
    12.7 -      returnMetaTask = returnSlv->metaTask;
    12.8 +      returnMetaTask = returnSlv->metaTasks;
    12.9        goto ReturnTheMetaTask;
   12.10      }
   12.11     
   12.12 @@ -102,7 +102,7 @@
   12.13           newD.to_task = returnSlv->numTimesAssignedToASlot;
   12.14           addToListOfArrays(Dependency, newD, semEnv->ctlDependenciesList);  
   12.15         }
   12.16 -      returnMetaTask = returnSlv->metaTask;
   12.17 +      returnMetaTask = returnSlv->metaTasks;
   12.18      }
   12.19     else //returnSlv != NULL
   12.20      { //assignSlv->numTimesAssigned++;
    13.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c	Wed Jan 16 01:50:26 2013 -0800
    13.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c	Tue Feb 05 20:23:27 2013 -0800
    13.3 @@ -183,8 +183,8 @@
    13.4  
    13.5        //For PRServ, caller needs ptr to created thread returned to it
    13.6     requestingSlv->dataRetFromReq = newSlv;
    13.7 -   resume_slaveVP(requestingSlv , semEnv );
    13.8 -   resume_slaveVP( newSlv,        semEnv );
    13.9 +   PR_PI__make_slave_ready(requestingSlv , semEnv );
   13.10 +   PR_PI__make_slave_ready( newSlv,        semEnv );
   13.11   }
   13.12  
   13.13  /*Initialize semantic data struct..  this initializer doesn't need any input,
   13.14 @@ -193,7 +193,7 @@
   13.15   * use the PR_PI__give_sem_data  inside the create handler, and fill in the
   13.16   * semData values there.
   13.17   */
   13.18 -void * createInitialSemanticData( )
   13.19 +void * PRServ__create_lang_data_in_slave( )
   13.20   { PRServSemData *semData;
   13.21   
   13.22     semData = PR_PI__malloc( sizeof(PRServSemData) );
   13.23 @@ -233,7 +233,7 @@
   13.24        if( parentTaskStub->isWaitingForChildTasksToEnd )
   13.25          return; //still waiting on tasks (should be impossible)
   13.26        else //parent free to resume
   13.27 -        resume_slaveVP( PR_PI__give_slave_assigned_to(parentTaskStub), semEnv );
   13.28 +        PR_PI__make_slave_ready( PR_PI__give_slave_assigned_to(parentTaskStub), semEnv );
   13.29      }
   13.30     
   13.31        //check if this is last child of ended parent (note, not possible to
   13.32 @@ -471,7 +471,7 @@
   13.33      } //for argNum
   13.34     
   13.35        //resume the parent, creator
   13.36 -   resume_slaveVP( semReq->callingSlv, semEnv );
   13.37 +   PR_PI__make_slave_ready( semReq->callingSlv, semEnv );
   13.38  
   13.39     return;
   13.40   }
   13.41 @@ -539,7 +539,7 @@
   13.42         parentStub->numLiveChildTasks == 0)
   13.43      {
   13.44        parentStub->isWaitingForChildTasksToEnd = FALSE;
   13.45 -      resume_slaveVP( PR_PI__give_slave_assigned_to(parentStub), semEnv );
   13.46 +      PR_PI__make_slave_ready( PR_PI__give_slave_assigned_to(parentStub), semEnv );
   13.47      }
   13.48     
   13.49        //Check if parent ended, and this was last descendent, then free it
   13.50 @@ -766,8 +766,8 @@
   13.51        receiverSlv->dataRetFromReq = semReq->msg;
   13.52  
   13.53           //bring both processors back from suspend
   13.54 -      resume_slaveVP( senderSlv,   semEnv );
   13.55 -      resume_slaveVP( receiverSlv, semEnv );
   13.56 +      PR_PI__make_slave_ready( senderSlv,   semEnv );
   13.57 +      PR_PI__make_slave_ready( receiverSlv, semEnv );
   13.58  
   13.59        return;
   13.60      }
   13.61 @@ -849,8 +849,8 @@
   13.62        receiverSlv->dataRetFromReq = semReq->msg;
   13.63  
   13.64           //bring both processors back from suspend
   13.65 -      resume_slaveVP( senderSlv,   semEnv );
   13.66 -      resume_slaveVP( receiverSlv, semEnv );
   13.67 +      PR_PI__make_slave_ready( senderSlv,   semEnv );
   13.68 +      PR_PI__make_slave_ready( receiverSlv, semEnv );
   13.69              
   13.70        return;
   13.71      }
   13.72 @@ -936,8 +936,8 @@
   13.73          addToListOfArrays(Unit,u,semEnv->ntonGroups[groupId]->receivers);
   13.74         #endif
   13.75        
   13.76 -      resume_slaveVP( senderSlv,   semEnv );
   13.77 -      resume_slaveVP( receiverSlv, semEnv );
   13.78 +      PR_PI__make_slave_ready( senderSlv,   semEnv );
   13.79 +      PR_PI__make_slave_ready( receiverSlv, semEnv );
   13.80  
   13.81        return;
   13.82      }
   13.83 @@ -1005,8 +1005,8 @@
   13.84           //bring both processors back from suspend
   13.85        PR_PI__free( waitingReq );
   13.86  
   13.87 -      resume_slaveVP( senderSlv,   semEnv );
   13.88 -      resume_slaveVP( receiverSlv, semEnv );
   13.89 +      PR_PI__make_slave_ready( senderSlv,   semEnv );
   13.90 +      PR_PI__make_slave_ready( receiverSlv, semEnv );
   13.91  
   13.92        return;
   13.93      }
   13.94 @@ -1028,7 +1028,7 @@
   13.95     
   13.96     if( taskStub->numLiveChildTasks == 0 )
   13.97      {    //nobody to wait for, resume
   13.98 -      resume_slaveVP( requestingSlv, semEnv );
   13.99 +      PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.100      }
  13.101     else  //have to wait, mark waiting
  13.102      {        
  13.103 @@ -1048,7 +1048,7 @@
  13.104  
  13.105     ptr = PR_PI__malloc( semReq->sizeToMalloc );
  13.106     requestingSlv->dataRetFromReq = ptr;
  13.107 -   resume_slaveVP( requestingSlv, semEnv );
  13.108 +   PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.109   }
  13.110  
  13.111  /*
  13.112 @@ -1058,7 +1058,7 @@
  13.113   {
  13.114           DEBUG__printf1(dbgRqstHdlr,"Free request from processor %d",requestingSlv->slaveID)
  13.115     PR_PI__free( semReq->ptrToFree );
  13.116 -   resume_slaveVP( requestingSlv, semEnv );
  13.117 +   PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.118   }
  13.119  
  13.120  
  13.121 @@ -1074,7 +1074,7 @@
  13.122     if( singleton->hasFinished )
  13.123      {    //the code that sets the flag to true first sets the end instr addr
  13.124        reqstingSlv->dataRetFromReq = singleton->endInstrAddr;
  13.125 -      resume_slaveVP( reqstingSlv, semEnv );
  13.126 +      PR_PI__make_slave_ready( reqstingSlv, semEnv );
  13.127        return;
  13.128      }
  13.129     else if( singleton->hasBeenStarted )
  13.130 @@ -1086,7 +1086,7 @@
  13.131      {    //hasn't been started, so this is the first attempt at the singleton
  13.132        singleton->hasBeenStarted = TRUE;
  13.133        reqstingSlv->dataRetFromReq = 0x0;
  13.134 -      resume_slaveVP( reqstingSlv, semEnv );
  13.135 +      PR_PI__make_slave_ready( reqstingSlv, semEnv );
  13.136        return;
  13.137      }
  13.138   }
  13.139 @@ -1139,10 +1139,10 @@
  13.140      {    //they will resume inside start singleton, then jmp to end singleton
  13.141        resumingSlv = readPrivQ( waitQ );
  13.142        resumingSlv->dataRetFromReq = singleton->endInstrAddr;
  13.143 -      resume_slaveVP( resumingSlv, semEnv );
  13.144 +      PR_PI__make_slave_ready( resumingSlv, semEnv );
  13.145      }
  13.146  
  13.147 -   resume_slaveVP( requestingSlv, semEnv );
  13.148 +   PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.149  
  13.150  }
  13.151  void inline
  13.152 @@ -1177,7 +1177,7 @@
  13.153   {
  13.154           DEBUG__printf1(dbgRqstHdlr,"Atomic request from processor %d",requestingSlv->slaveID)
  13.155     semReq->fnToExecInMaster( semReq->dataForFn );
  13.156 -   resume_slaveVP( requestingSlv, semEnv );
  13.157 +   PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.158   }
  13.159  
  13.160  /*First, it looks at the VP's semantic data, to see the highest transactionID
  13.161 @@ -1223,7 +1223,7 @@
  13.162     if( transStruc->VPCurrentlyExecuting == NULL )
  13.163      {
  13.164        transStruc->VPCurrentlyExecuting = requestingSlv;
  13.165 -      resume_slaveVP( requestingSlv, semEnv );
  13.166 +      PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.167      }
  13.168     else
  13.169      {    //note, might make future things cleaner if save request with VP and
  13.170 @@ -1279,7 +1279,7 @@
  13.171     transStruc->VPCurrentlyExecuting = waitingSlv;
  13.172  
  13.173     if( waitingSlv != NULL )
  13.174 -      resume_slaveVP( waitingSlv, semEnv );
  13.175 +      PR_PI__make_slave_ready( waitingSlv, semEnv );
  13.176  
  13.177 -   resume_slaveVP( requestingSlv, semEnv );
  13.178 +   PR_PI__make_slave_ready( requestingSlv, semEnv );
  13.179   }