changeset 289:744b5ff9851e Dev_ML

Merge
author Sean Halle <seanhalle@yahoo.com>
date Thu, 05 Sep 2013 18:08:14 -0700
parents c7142d15fc40 b02b34681414
children c63b498d0a00
files AnimationMaster.c PR.c PR__SS.c PR__int.c PR__int.h PR__structs.h Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h Services_Offered_by_PR/Services_Language/PRServ.h Services_Offered_by_PR/Services_Language/PRServ_SS.c
diffstat 19 files changed, 160 insertions(+), 257 deletions(-) [+]
line diff
     1.1 --- a/AnimationMaster.c	Thu Sep 05 18:05:11 2013 -0700
     1.2 +++ b/AnimationMaster.c	Thu Sep 05 18:08:14 2013 -0700
     1.3 @@ -34,6 +34,9 @@
     1.4  inline void
     1.5  handleThrowException( PRServiceReq *langReq, PRLangEnv *protoLangEnv );
     1.6  
     1.7 +void
     1.8 +debug_print_req(AnimSlot *slot, PRReqst *req);
     1.9 +
    1.10  //===========================================================================
    1.11  
    1.12  /*Note: there used to be a coreController that was another animation 
    1.13 @@ -73,7 +76,6 @@
    1.14     if( slot->workIsDone )
    1.15      { slot->workIsDone = FALSE;
    1.16        slot->needsWorkAssigned = TRUE;
    1.17 -//printf("top handle request: %d | reqType: %d\n", slot->coreSlotIsOn, (int32)req->reqType );fflush(stdin);
    1.18        
    1.19           //An Idle VP has no request to handle, so skip to assign..
    1.20        if( slot->slaveAssignedToSlot->typeOfVP != IdleVP && 
    1.21 @@ -592,3 +594,27 @@
    1.22     (*protoLangEnv->makeSlaveReadyFn)( langReq->requestingSlv, PR_int__give_lang_env(protoLangEnv) );
    1.23   }
    1.24  
    1.25 +void
    1.26 +debug_print_req(AnimSlot *slot, PRReqst *req)
    1.27 + {
    1.28 +   if(dbgMaster)
    1.29 +       { printf("top handle request: %d | reqType: ", slot->coreSlotIsOn );
    1.30 +         switch(req->reqType)
    1.31 +          { case TaskCreate: printf("TaskCreate \n"); break;
    1.32 +            case TaskEnd: printf("TaskEnd \n"); break;
    1.33 +            case   SlvCreate: printf("SlvCreate \n"); break;
    1.34 +            case SlvDissipate: printf("SlvDissipate \n"); break;
    1.35 +            case Language: printf("Language \n"); break;
    1.36 +            case Service: printf("Service \n"); break;
    1.37 +            case Hardware: printf("Hardware \n"); break;
    1.38 +            case IO: printf("IO \n"); break;
    1.39 +            case OSCall: printf("OSCall \n"); break;
    1.40 +            case LangShutdown: printf("LangShutdown \n"); break;
    1.41 +            case ProcessEnd: printf("ProcessEnd \n"); break;
    1.42 +            case PRShutdown: printf("PRShutdown \n"); break;
    1.43 +          } 
    1.44 +         fflush(stdin);
    1.45 +       }
    1.46 + }
    1.47 +
    1.48 +
     2.1 --- a/Defines/PR_defs__HW_constants.h	Thu Sep 05 18:05:11 2013 -0700
     2.2 +++ b/Defines/PR_defs__HW_constants.h	Thu Sep 05 18:08:14 2013 -0700
     2.3 @@ -15,6 +15,13 @@
     2.4     //This value is the number of hardware threads in the shared memory
     2.5     // machine
     2.6  #define NUM_CORES        4
     2.7 +   //Now, check if sequential mode is on, and set num cores to 1, so that
     2.8 +   // lang plugin code doesn't have to check for sequential mode
     2.9 +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
    2.10 +   #undef  NUM_CORES
    2.11 +   #define NUM_CORES 1
    2.12 +#endif
    2.13 +
    2.14  
    2.15     //tradeoff amortizing master fixed overhead vs imbalance potential
    2.16     // when work-stealing, can make bigger, at risk of losing cache affinity
     3.1 --- a/HW_Dependent_Primitives/PR__primitives.c	Thu Sep 05 18:05:11 2013 -0700
     3.2 +++ b/HW_Dependent_Primitives/PR__primitives.c	Thu Sep 05 18:08:14 2013 -0700
     3.3 @@ -18,14 +18,14 @@
     3.4   * carefully that it's safe)
     3.5   */
     3.6  inline void
     3.7 -PR_int__reset_slaveVP_to_TopLvlFn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr,
     3.8 +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr,
     3.9                                void    *dataParam)
    3.10   { void  *stackPtr;
    3.11  
    3.12  // Start of Hardware dependent part           
    3.13     
    3.14      //Set slave's instr pointer to a helper Fn that copies params from stack
    3.15 -   slaveVP->resumeInstrPtr  = (TopLevelFnPtr)&startUpTopLevelFn;
    3.16 +   slaveVP->resumeInstrPtr  = (BirthFnPtr)&startUpBirthFn;
    3.17     
    3.18      //fnPtr takes two params -- void *dataParam & void *animSlv
    3.19      // Stack grows *down*, so start it at highest stack addr, minus room
    3.20 @@ -81,7 +81,7 @@
    3.21     *((void**)stackPtr - 1) = (void*)fnPtr;        //what helper jmps to
    3.22     
    3.23      //Set slave's instr pointer to a helper Fn that copies params from stack
    3.24 -   slaveVP->resumeInstrPtr  = (TopLevelFnPtr)&jmpToOneParamFn;
    3.25 +   slaveVP->resumeInstrPtr  = (BirthFnPtr)&jmpToOneParamFn;
    3.26     
    3.27  // end of Hardware dependent part           
    3.28     
    3.29 @@ -123,7 +123,7 @@
    3.30     *((void**)stackPtr - 1) = (void*)fnPtr;        //what helper jmps to
    3.31     
    3.32      //Set slave's instr pointer to a helper Fn that copies params from stack
    3.33 -   slaveVP->resumeInstrPtr  = (TopLevelFnPtr)&jmpToTwoParamFn;
    3.34 +   slaveVP->resumeInstrPtr  = (BirthFnPtr)&jmpToTwoParamFn;
    3.35     
    3.36  // end of Hardware dependent part           
    3.37     
     4.1 --- a/HW_Dependent_Primitives/PR__primitives.h	Thu Sep 05 18:05:11 2013 -0700
     4.2 +++ b/HW_Dependent_Primitives/PR__primitives.h	Thu Sep 05 18:08:14 2013 -0700
     4.3 @@ -23,7 +23,7 @@
     4.4  masterSwitchToCoreCtlr(SlaveVP *nextSlave);
     4.5  
     4.6  void 
     4.7 -startUpTopLevelFn();
     4.8 +startUpBirthFn();
     4.9  
    4.10  void 
    4.11  jmpToOneParamFn();
     5.1 --- a/HW_Dependent_Primitives/PR__primitives_asm.s	Thu Sep 05 18:05:11 2013 -0700
     5.2 +++ b/HW_Dependent_Primitives/PR__primitives_asm.s	Thu Sep 05 18:08:14 2013 -0700
     5.3 @@ -14,8 +14,8 @@
     5.4  
     5.5  //Trick for 64 bit arch -- copies args from stack into regs, then does jmp to
     5.6  // the top-level function, which was pointed to by the stack-ptr
     5.7 -.globl startUpTopLevelFn
     5.8 -startUpTopLevelFn:
     5.9 +.globl startUpBirthFn
    5.10 +startUpBirthFn:
    5.11      movq    %rdi      , %rsi #get second argument from first argument of switchSlv
    5.12      movq    0x08(%rsp), %rdi #get first argument from stack
    5.13      movq    (%rsp)    , %rax #get top-level function's addr from stack
     6.1 --- a/PR.c	Thu Sep 05 18:05:11 2013 -0700
     6.2 +++ b/PR.c	Thu Sep 05 18:08:14 2013 -0700
     6.3 @@ -65,7 +65,7 @@
     6.4     PR_SS__create_topEnv();
     6.5     
     6.6    #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
     6.7 -   printf( "\n\n Running in SEQUENTIAL mode \n\n" );
     6.8 +   printf( "\n\n Running in SEQUENTIAL mode -- NUM_CORES: %d \n\n", NUM_CORES );
     6.9        //Only difference between version with an OS thread pinned to each core and
    6.10        // the sequential version of PR is PR__init_Seq, this, and coreCtlr_Seq.
    6.11  
    6.12 @@ -100,7 +100,7 @@
    6.13   * 
    6.14   */
    6.15  PRProcess *
    6.16 -PR__create_process( TopLevelFnPtr seed_Fn, void *seedData )
    6.17 +PR__create_process( BirthFnPtr seed_Fn, void *seedData )
    6.18   { SlaveVP    *seedSlv;
    6.19     PRProcess  *process;
    6.20     PRLangEnv **langEnvs, **langEnvsList;
    6.21 @@ -232,9 +232,11 @@
    6.22        process->executionIsComplete = TRUE;
    6.23      }
    6.24    #else
    6.25 -      //First get the "ACK" lock, then do normal wait for signal, then release
    6.26 -      // ACK lock, to let end-process know it can free the process struct
    6.27 -   pthread_mutex_lock( &(process->doneAckLock) );   
    6.28 +      //This is called from main thread, so must use OS thread constructs to
    6.29 +      // force the main thread to block (suspend) until it is signalled that
    6.30 +      // the process is complete.  One issue is that the mutex and cond variable
    6.31 +      // are inside the process data struct, which is freed when the process
    6.32 +      // ends!
    6.33     pthread_mutex_lock( &(process->doneLock) );
    6.34     while( process->executionIsComplete != TRUE )
    6.35      {
     7.1 --- a/PR__PI.c	Thu Sep 05 18:05:11 2013 -0700
     7.2 +++ b/PR__PI.c	Thu Sep 05 18:08:14 2013 -0700
     7.3 @@ -48,6 +48,14 @@
     7.4         }
     7.5      }
     7.6   }
     7.7 +/*Make slave ready, without having to know the lang env.. just the magic num
     7.8 + */
     7.9 +void
    7.10 +PR_PI__make_slave_ready_for_lang( SlaveVP *slave, int32 magicNum )
    7.11 + { void *langEnv;
    7.12 +   langEnv = PR_PI__give_lang_env_for_slave( slave, magicNum );
    7.13 +   PR_PI__make_slave_ready( slave, langEnv );
    7.14 + }
    7.15  
    7.16  /*Any langlet can transfer slaves over to be resumed in PRServ.. the resume Fn
    7.17   * is registered in the PRServ lang env during process creation.
     8.1 --- a/PR__SS.c	Thu Sep 05 18:05:11 2013 -0700
     8.2 +++ b/PR__SS.c	Thu Sep 05 18:08:14 2013 -0700
     8.3 @@ -372,10 +372,13 @@
     8.4           // return.
     8.5        return;
     8.6       #else
     8.7 +      //Here, must use OS thread constructs.. the main thread is waiting for
     8.8 +      // PR process to complete.  So, at this point, cause main to resume.
     8.9 +       
    8.10        pthread_mutex_lock(     &(process->doneLock) );
    8.11        process->executionIsComplete = TRUE;
    8.12 +      pthread_cond_broadcast( &(process->doneCond) );
    8.13        pthread_mutex_unlock(   &(process->doneLock) );
    8.14 -      pthread_cond_broadcast( &(process->doneCond) );
    8.15           //now wait for woken waiter to Ack, then free the process struct
    8.16        pthread_mutex_lock(     &(process->doneAckLock)  ); //BUG:? may be a race
    8.17        pthread_mutex_unlock(   &(process->doneAckLock)  );  
    8.18 @@ -411,7 +414,7 @@
    8.19     AnimSlot **animSlots;
    8.20        //create the shutdown processors, one for each core controller -- put them
    8.21        // directly into the slots
    8.22 -   PR_int__get_master_lock();
    8.23 +   PR_int__get_wrapper_lock();
    8.24     for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
    8.25      {    //Note, this is running in the master
    8.26        shutDownSlv = PR_SS__create_shutdown_slave();
     9.1 --- a/PR__WL.c	Thu Sep 05 18:05:11 2013 -0700
     9.2 +++ b/PR__WL.c	Thu Sep 05 18:08:14 2013 -0700
     9.3 @@ -116,7 +116,7 @@
     9.4   
     9.5  inline
     9.6  void
     9.7 -PR_WL__send_create_task_req( TopLevelFn fn, void *initData, void *langReq, 
     9.8 +PR_WL__send_create_task_req( BirthFn fn, void *initData, void *langReq, 
     9.9       int32 *taskID, CreateHandler handler, SlaveVP *animSlv, int32 magicNumber)
    9.10   { PRReqst req;
    9.11   
    9.12 @@ -165,7 +165,7 @@
    9.13  //WARNING: not updated.. may be buggy
    9.14     req = PR_int__malloc( sizeof(PRReqst) );
    9.15     req->reqType         = Language;
    9.16 -   req->langReq          = langReqData;
    9.17 +   req->langReq         = langReqData;
    9.18     req->nextReqst       = callingSlv->request;
    9.19     callingSlv->request  = req;
    9.20   }
    10.1 --- a/PR__WL.h	Thu Sep 05 18:05:11 2013 -0700
    10.2 +++ b/PR__WL.h	Thu Sep 05 18:08:14 2013 -0700
    10.3 @@ -40,7 +40,7 @@
    10.4  PR__start();
    10.5  
    10.6  PRProcess *
    10.7 -PR__create_process( TopLevelFnPtr seed_Fn, void *seedData );
    10.8 +PR__create_process( BirthFnPtr seed_Fn, void *seedData );
    10.9  
   10.10  void
   10.11  PR__end_seedVP( SlaveVP *seedSlv );
    11.1 --- a/PR__int.c	Thu Sep 05 18:05:11 2013 -0700
    11.2 +++ b/PR__int.c	Thu Sep 05 18:08:14 2013 -0700
    11.3 @@ -30,7 +30,7 @@
    11.4   */
    11.5  inline
    11.6  SlaveVP *
    11.7 -PR_int__create_slaveVP_helper( TopLevelFnPtr fnPtr, void *dataParam )
    11.8 +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam )
    11.9   { SlaveVP *newSlv;
   11.10     void    *stackLocs;
   11.11     
   11.12 @@ -46,10 +46,14 @@
   11.13        
   11.14     newSlv->numTimesAssignedToASlot  = 0;  
   11.15  
   11.16 -   newSlv->langDatas = NULL;
   11.17 -   newSlv->metaTasks     = NULL;
   11.18 +      
   11.19 +   newSlv->langDatas = 
   11.20 +      (PRLangData **)PR_int__make_collection_of_size( NUM_IN_COLLECTION );
   11.21 +           
   11.22 +   newSlv->metaTasks = 
   11.23 +      (PRMetaTask **) PR_int__make_collection_of_size( NUM_IN_COLLECTION );
   11.24  
   11.25 -   PR_int__reset_slaveVP_to_TopLvlFn( newSlv, fnPtr, dataParam );
   11.26 +   PR_int__reset_slaveVP_to_BirthFn( newSlv, fnPtr, dataParam );
   11.27     
   11.28     //============================= MEASUREMENT STUFF ========================
   11.29     #ifdef PROBES__TURN_ON_STATS_PROBES
   11.30 @@ -61,23 +65,17 @@
   11.31     #endif
   11.32     //========================================================================
   11.33  
   11.34 -   newSlv->typeOfVP            = GenericSlave;
   11.35 +   newSlv->typeOfVP            = GenericSlave; //may be changed later!
   11.36     
   11.37     return newSlv;
   11.38   }
   11.39  
   11.40  inline
   11.41  SlaveVP *
   11.42 -PR_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process )
   11.43 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process )
   11.44   { SlaveVP *newSlv;
   11.45   
   11.46     newSlv = PR_int__create_slaveVP_helper( fnPtr, dataParam );
   11.47 -      
   11.48 -   newSlv->langDatas = 
   11.49 -      (PRLangData **)PR_int__make_collection_of_size( NUM_IN_COLLECTION );
   11.50 -           
   11.51 -   newSlv->metaTasks = 
   11.52 -      (PRMetaTask **) PR_int__make_collection_of_size( NUM_IN_COLLECTION );
   11.53     
   11.54     process->numLiveGenericSlvs += 1;
   11.55     
   11.56 @@ -441,7 +439,7 @@
   11.57                 //if work found, put into slot, and adjust flags and state
   11.58     slot->slaveAssignedToSlot = slave;
   11.59     slave->animSlotAssignedTo = slot;
   11.60 -   slot->needsWorkAssigned  = FALSE;
   11.61 +   slot->needsWorkAssigned   = FALSE;
   11.62  
   11.63    #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
   11.64        //have a slave to be assigned to the slot
   11.65 @@ -486,7 +484,7 @@
   11.66     slotSlv = _PRTopEnv->slotTaskSlvs[coreNum][slotNum];
   11.67  
   11.68       //point slave to task's function
   11.69 -   PR_int__reset_slaveVP_to_TopLvlFn( slotSlv, protoMetaTask->topLevelFn, protoMetaTask->initData );
   11.70 +   PR_int__reset_slaveVP_to_BirthFn( slotSlv, protoMetaTask->topLevelFn, protoMetaTask->initData );
   11.71     PR_int__insert_meta_task_into_slave( protoMetaTask, slotSlv );
   11.72     slotSlv->processSlaveIsIn = protoMetaTask->processTaskIsIn;
   11.73     PR_int__put_slave_into_slot( slotSlv, slot );
   11.74 @@ -700,7 +698,7 @@
   11.75      { protoLangEnv = PR_int__give_proto_lang_env_for_slave( slave, magicNum );
   11.76        if(protoLangEnv->langDataCreator == NULL) 
   11.77           PR_int__error("register a lang data creator");
   11.78 -         //This will call PR_PI__create_lang_data_in_slave
   11.79 +         //This will call PR_PI__create_lang_data_in_slave -- puts it into slave
   11.80        return (*protoLangEnv->langDataCreator)( slave );
   11.81      }
   11.82   }
   11.83 @@ -904,14 +902,46 @@
   11.84  PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock );
   11.85  
   11.86  inline void
   11.87 -PR_int__get_master_lock()
   11.88 - { int32 *addrOfMasterLock;
   11.89 +PR_int__get_wrapper_lock()
   11.90 + { int32 *addrOfWrapperLock;
   11.91   
   11.92    #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
   11.93              return;
   11.94    #endif
   11.95  
   11.96 -   addrOfMasterLock = &(_PRTopEnv->masterLock);
   11.97 +   addrOfWrapperLock = &(_PRTopEnv->wrapperLock);
   11.98 +
   11.99 +   int numTriesToGetLock = 0;
  11.100 +   int gotLock = 0;
  11.101 +   
  11.102 +//            MEAS__Capture_Pre_Master_Lock_Point;
  11.103 +   while( !gotLock ) //keep going until get master lock
  11.104 +    { 
  11.105 +      numTriesToGetLock++;   //if too many, means too much contention
  11.106 +      if( numTriesToGetLock > NUM_TRIES_BEFORE_DO_BACKOFF )
  11.107 +       { PR_int__backoff_for_TooLongToGetLock( numTriesToGetLock );
  11.108 +       }
  11.109 +      if( numTriesToGetLock > MASTERLOCK_RETRIES_BEFORE_YIELD ) 
  11.110 +       { numTriesToGetLock = 0; 
  11.111 +         pthread_yield();
  11.112 +       }
  11.113 +   
  11.114 +         //try to get the lock
  11.115 +      gotLock = __sync_bool_compare_and_swap( addrOfWrapperLock,
  11.116 +                                                         UNLOCKED, LOCKED );
  11.117 +    }
  11.118 +//            MEAS__Capture_Post_Master_Lock_Point;
  11.119 + }
  11.120 +
  11.121 +inline void
  11.122 +PR_int__get_malloc_lock()
  11.123 + { int32 *addrOfMallocLock;
  11.124 + 
  11.125 +  #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
  11.126 +            return;
  11.127 +  #endif
  11.128 +
  11.129 +   addrOfMallocLock = &(_PRTopEnv->mallocLock);
  11.130  
  11.131     int numTriesToGetLock = 0;
  11.132     int gotLock = 0;
  11.133 @@ -929,7 +959,7 @@
  11.134         }
  11.135     
  11.136           //try to get the lock
  11.137 -      gotLock = __sync_bool_compare_and_swap( addrOfMasterLock,
  11.138 +      gotLock = __sync_bool_compare_and_swap( addrOfMallocLock,
  11.139                                                           UNLOCKED, LOCKED );
  11.140      }
  11.141              MEAS__Capture_Post_Master_Lock_Point;
    12.1 --- a/PR__int.h	Thu Sep 05 18:05:11 2013 -0700
    12.2 +++ b/PR__int.h	Thu Sep 05 18:08:14 2013 -0700
    12.3 @@ -21,7 +21,7 @@
    12.4  
    12.5  inline
    12.6  void
    12.7 -PR_int__reset_slaveVP_to_TopLvlFn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr,
    12.8 +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr,
    12.9                                void    *dataParam);
   12.10  
   12.11  inline
   12.12 @@ -39,11 +39,11 @@
   12.13  //===========================================================================
   12.14  inline
   12.15  SlaveVP *
   12.16 -PR_int__create_slaveVP_helper( TopLevelFnPtr fnPtr, void *dataParam );
   12.17 +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam );
   12.18  
   12.19  inline
   12.20  SlaveVP *
   12.21 -PR_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam, PRProcess *process );
   12.22 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process );
   12.23  
   12.24  SlaveVP *
   12.25  PR_int__get_recycled_slot_slave( );
   12.26 @@ -244,9 +244,16 @@
   12.27  PR_int__strDup( char *str );
   12.28  
   12.29  inline void
   12.30 -PR_int__get_master_lock();
   12.31 +PR_int__get_wrapper_lock();
   12.32  
   12.33 -#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED
   12.34 +inline void
   12.35 +PR_int__get_malloc_lock();
   12.36 +
   12.37 +#define PR_int__release_master_lock()  _PRTopEnv->masterLock  = UNLOCKED
   12.38 +
   12.39 +#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED
   12.40 +
   12.41 +#define PR_int__release_malloc_lock()  _PRTopEnv->mallocLock  = UNLOCKED
   12.42  
   12.43  inline uint32_t
   12.44  PR_int__randomNumber();
    13.1 --- a/PR__structs.h	Thu Sep 05 18:05:11 2013 -0700
    13.2 +++ b/PR__structs.h	Thu Sep 05 18:08:14 2013 -0700
    13.3 @@ -43,8 +43,8 @@
    13.4  typedef void     (*LangMetaTaskFreer)  ( void * ); //lang meta task to free
    13.5  typedef void     (*MakeSlaveReadyFn)   ( SlaveVP *, void * ); //slave and langEnv
    13.6  typedef void     (*MakeTaskReadyFn)    ( void *, void * ); //langTask and langEnv
    13.7 -typedef void     (*TopLevelFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
    13.8 -typedef void       TopLevelFn      ( void *, SlaveVP * ); //initData, animSlv
    13.9 +typedef void     (*BirthFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
   13.10 +typedef void       BirthFn      ( void *, SlaveVP * ); //initData, animSlv
   13.11  typedef void     (*ResumeSlvFnPtr) ( SlaveVP *, void * );
   13.12        //=========== MEASUREMENT STUFF ==========
   13.13          MEAS__Insert_Counter_Handler
   13.14 @@ -121,17 +121,17 @@
   13.15  enum PRReqstType  //avoid starting enums at 0, for debug reasons
   13.16   {
   13.17     TaskCreate = 1,
   13.18 -   TaskEnd = 2,
   13.19 -   SlvCreate = 3,
   13.20 -   SlvDissipate = 4,
   13.21 -   Language = 5,
   13.22 -   Service = 6,       //To invoke a PR provided equivalent of a language request (ex: probe)
   13.23 -   Hardware = 7,
   13.24 -   IO = 8,
   13.25 -   OSCall = 9, 
   13.26 -   LangShutdown = 10,
   13.27 -   ProcessEnd = 11,
   13.28 -   PRShutdown = 12
   13.29 +   TaskEnd,
   13.30 +   SlvCreate,
   13.31 +   SlvDissipate,
   13.32 +   Language,
   13.33 +   Service,       //To invoke a PR provided equivalent of a language request (ex: probe)
   13.34 +   Hardware,
   13.35 +   IO,
   13.36 +   OSCall, 
   13.37 +   LangShutdown,
   13.38 +   ProcessEnd,
   13.39 +   PRShutdown
   13.40   };
   13.41  
   13.42  
   13.43 @@ -143,7 +143,7 @@
   13.44     int32              langMagicNumber;
   13.45     SlaveVP           *requestingSlave;
   13.46     
   13.47 -   TopLevelFnPtr      topLevelFn;
   13.48 +   BirthFnPtr      topLevelFn;
   13.49     void              *initData;
   13.50     int32             *ID;
   13.51     
   13.52 @@ -152,6 +152,7 @@
   13.53        // fn directly into the request..  might change to this for all requests
   13.54     RequestHandler    handler; //pointer to handler fn 
   13.55     CreateHandler     createHdlr; //special because returns something
   13.56 +   int32             createSuspendedGroup; //must be non-zero
   13.57     
   13.58     PRReqst *nextReqst;
   13.59   };
   13.60 @@ -263,6 +264,10 @@
   13.61     int8             falseSharePad1[256 - sizeof(void*)];
   13.62     int32            masterLock;          //offset to this field used in asm
   13.63     int8             falseSharePad2[256 - sizeof(int32)];
   13.64 +   int32            wrapperLock;         //offset to this field used in asm
   13.65 +   int8             falseSharePad3[256 - sizeof(int32)];
   13.66 +   int32            mallocLock;          //offset to this field used in asm
   13.67 +   int8             falseSharePad4[256 - sizeof(int32)];
   13.68        //============ below this, no fields are used in asm =============
   13.69  
   13.70        //Basic PR infrastructure
   13.71 @@ -373,7 +378,7 @@
   13.72     int32          *ID;              //is standard PR ID
   13.73     PRProcess      *processTaskIsIn;
   13.74     SlaveVP        *slaveAssignedTo; //not valid until task animated
   13.75 -   TopLevelFnPtr   topLevelFn;      //This is the Fn executes as the task
   13.76 +   BirthFnPtr   topLevelFn;      //This is the Fn executes as the task
   13.77     void           *initData;        //The data taken by the function
   13.78     LangMetaTaskFreer freer;
   13.79     bool32          goAheadAndFree;
    14.1 --- a/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c	Thu Sep 05 18:05:11 2013 -0700
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,156 +0,0 @@
    14.4 -/*
    14.5 - * 
    14.6 - * author: Nina Engelhardt
    14.7 - */
    14.8 -
    14.9 -#include "MEAS__Counter_Recording.h"
   14.10 -#include "PR_impl/PR.h"
   14.11 -//#include "../PRServ.h"
   14.12 -
   14.13 -#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
   14.14 -
   14.15 -void 
   14.16 -PR_MEAS__init_counter_data_structs_for_Lang( SlaveVP *slave, int32 magicNum )
   14.17 - {
   14.18 -   PRServLangEnv *langEnv = 
   14.19 -                (PRServLangEnv *)PR_SS__give_lang_env_for_slave( slave, magicNum );
   14.20 -   int i;
   14.21 -   for(i=0;i<NUM_CORES;i++)
   14.22 -    { langEnv->counterList[i] = makeListOfArrays(sizeof(CounterEvent), 128);
   14.23 -    }
   14.24 - }
   14.25 -
   14.26 -/*Pass file by side effect..
   14.27 - *The reason is that using doAllInListOfArrays, to which one passes the pointer
   14.28 - * to a function, which is then applied to all the elements..  but, that fn
   14.29 - * can only take one input -- the element from the list of arrays..  so, it
   14.30 - * can't also be passed the file..  hence pass the file by side effect
   14.31 - * 
   14.32 - *However, multiple cores could be trying to do this..  so, create a separate
   14.33 - * lock just for counters, and acquire that when set the file, then release
   14.34 - * once all the printing is done.
   14.35 - */
   14.36 -void 
   14.37 -PR_MEAS__set_counter_file(FILE* f)
   14.38 - {
   14.39 -   acquire counter lock
   14.40 -   counterfile = f;
   14.41 - }
   14.42 -
   14.43 -PR_MEAS__release_counter_file()
   14.44 - {
   14.45 -   release counter lock
   14.46 - }
   14.47 -
   14.48 -void 
   14.49 -PR_MEAS__addToListOfArraysCounterEvent(CounterEvent value, ListOfArrays* list)
   14.50 - {
   14.51 -   int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; 
   14.52 -   if(offset_in_fragment == 0)
   14.53 -    { void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); 
   14.54 -     addToDynArray(newBlock,list->dim1info); 
   14.55 -    } 
   14.56 -   CounterEvent* typedFragment = (CounterEvent*) ((list->dim1)[list->dim1info->numInArray -1]); 
   14.57 -   typedFragment[offset_in_fragment] = value; 
   14.58 -   list->next_free_index++; 
   14.59 - }
   14.60 -
   14.61 -void 
   14.62 -PR_MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs)
   14.63 - {
   14.64 -   if (pr->typeOfVP == Master_VP || pr->typeOfVP == ShutdownVP)
   14.65 -    { //Only save values for application work, done in a SlaveVP
   14.66 -      return;
   14.67 -    }
   14.68 -
   14.69 -   //Note: have made many changes without compiler flag turned on, nor test..
   14.70 -   PRLangEnv *langEnv = 
   14.71 -      PR_int__give_proto_lang_env_from_slave( pr, magicNum);
   14.72 -
   14.73 -   CounterEvent e;
   14.74 -   e.event_type = evt_type;
   14.75 -   e.vp = vpid;
   14.76 -   e.task = task;
   14.77 -
   14.78 -   e.cycles = cycles;
   14.79 -   e.instrs = instrs;
   14.80 -
   14.81 -   if(pr)
   14.82 -    { e.coreID = pr->coreAnimatedBy;
   14.83 -      e.slot = pr->animSlotAssignedTo;
   14.84 -    } 
   14.85 -   else 
   14.86 -    { e.coreID = -1;
   14.87 -      e.slot = NULL;
   14.88 -    }
   14.89 -
   14.90 -   int corenum;
   14.91 -
   14.92 -   if(pr) 
   14.93 -      corenum = pr->coreAnimatedBy; 
   14.94 -   else 
   14.95 -      return; 
   14.96 -
   14.97 -   if(evt_type==Work_start || evt_type==Work_end || evt_type==AppResponderInvocation_start)
   14.98 -    { addToListOfArrays_ext(CounterEvent,e,langEnv->counterList[corenum]);
   14.99 -    } 
  14.100 -   else 
  14.101 -    { PR_MEAS__addToListOfArraysCounterEvent(e,langEnv->counterList[corenum]);
  14.102 -    }
  14.103 - }
  14.104 -
  14.105 -
  14.106 -
  14.107 -void 
  14.108 -PR_MEAS__print_counter_event_to_file( void* _e )
  14.109 - {
  14.110 -   CounterEvent* e = (CounterEvent*) _e;
  14.111 -   fprintf(counterfile, "event, ");
  14.112 -   switch(e->event_type)
  14.113 -    {
  14.114 -      case AppResponderInvocation_start:
  14.115 -          fprintf(counterfile, "AppResponderInvocation_start");
  14.116 -          break;
  14.117 -      case AppResponder_start:
  14.118 -          fprintf(counterfile, "AppResponder_start");
  14.119 -          break;
  14.120 -      case AppResponder_end:
  14.121 -          fprintf(counterfile, "AppResponder_end");
  14.122 -          break;
  14.123 -      case AssignerInvocation_start:
  14.124 -          fprintf(counterfile, "AssignerInvocation_start");
  14.125 -          break;
  14.126 -      case NextAssigner_start:
  14.127 -          fprintf(counterfile, "NextAssigner_start");
  14.128 -          break;
  14.129 -      case Assigner_start:
  14.130 -          fprintf(counterfile, "Assigner_start");
  14.131 -          break;
  14.132 -      case Assigner_end:
  14.133 -          fprintf(counterfile, "Assigner_end");
  14.134 -          break;
  14.135 -      case Work_end:
  14.136 -          fprintf(counterfile, "Work_end");
  14.137 -          break;
  14.138 -      case Work_start:
  14.139 -          fprintf(counterfile, "Work_start");
  14.140 -          break;
  14.141 -      case HwResponderInvocation_start:
  14.142 -          fprintf(counterfile, "HwResponderInvocation_start");
  14.143 -          break;
  14.144 -      case Timestamp_start:
  14.145 -          fprintf(counterfile, "Timestamp_start");
  14.146 -          break;
  14.147 -      case Timestamp_end:
  14.148 -          fprintf(counterfile, "Timestamp_end");
  14.149 -          break;
  14.150 -      default:
  14.151 -          fprintf(counterfile, "unknown event");
  14.152 -    }
  14.153 -   fprintf(counterfile,", %d, %d, %llu, %llu",e->vp,e->task,e->cycles,e->instrs);
  14.154 -   if(e->coreID >=0)
  14.155 -   fprintf(counterfile,", %d",e->coreID);
  14.156 -   fprintf(counterfile,"\n");
  14.157 -   fflush(counterfile);
  14.158 - }
  14.159 -#endif
    15.1 --- a/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h	Thu Sep 05 18:05:11 2013 -0700
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,36 +0,0 @@
    15.4 -/* 
    15.5 - * File:   PR_MEAS__Counter_Recording.h
    15.6 - * Author: nengel
    15.7 - *
    15.8 - * Created on January 11, 2012, 3:03 PM
    15.9 - */
   15.10 -
   15.11 -#ifndef PR_MEAS__COUNTER_RECORDING_H
   15.12 -#define	PR_MEAS__COUNTER_RECORDING_H
   15.13 -
   15.14 -#include "PR_impl/PR.h"
   15.15 -
   15.16 -typedef struct 
   15.17 - {
   15.18 -   int event_type;
   15.19 -   int coreID;
   15.20 -   AnimSlot* slot;
   15.21 -   int vp;
   15.22 -   int task;
   15.23 -   uint64 cycles;
   15.24 -   uint64 instrs;
   15.25 - } 
   15.26 -CounterEvent;
   15.27 -
   15.28 -FILE* counterfile; //pass file handle via side effect because
   15.29 -                   // doAllInListOfArrays only takes Fns with a single input
   15.30 -
   15.31 -void PR_MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum );
   15.32 -
   15.33 -void PR_MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs);
   15.34 -
   15.35 -void PR_MEAS__set_counter_file(FILE* f);
   15.36 -
   15.37 -void PR_MEAS__print_counter_event_to_file( void* _e );
   15.38 -#endif	/* PRServ_COUNTER_RECORDING_H */
   15.39 -
    16.1 --- a/Services_Offered_by_PR/Measurement_and_Stats/probes.c	Thu Sep 05 18:05:11 2013 -0700
    16.2 +++ b/Services_Offered_by_PR/Measurement_and_Stats/probes.c	Thu Sep 05 18:08:14 2013 -0700
    16.3 @@ -163,11 +163,11 @@
    16.4  PR_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv )
    16.5   { IntervalProbe *probe;
    16.6  
    16.7 -   PR_int__get_master_lock();
    16.8 +   PR_int__get_wrapper_lock();
    16.9     probe = _PRTopEnv->intervalProbes[ probeID ];
   16.10  
   16.11     addValueIntoTable(probe->nameStr, probe, _PRTopEnv->probeNameHashTbl);
   16.12 -   PR_int__release_master_lock();
   16.13 +   PR_int__release_wrapper_lock();
   16.14   }
   16.15  
   16.16  
    17.1 --- a/Services_Offered_by_PR/Memory_Handling/vmalloc.c	Thu Sep 05 18:05:11 2013 -0700
    17.2 +++ b/Services_Offered_by_PR/Memory_Handling/vmalloc.c	Thu Sep 05 18:08:14 2013 -0700
    17.3 @@ -291,9 +291,9 @@
    17.4  PR_WL__malloc( int32 sizeRequested )
    17.5   { void *ret;
    17.6   
    17.7 -   PR_int__get_master_lock();
    17.8 +   PR_int__get_malloc_lock();
    17.9     ret = PR_int__malloc( sizeRequested );
   17.10 -   PR_int__release_master_lock();
   17.11 +   PR_int__release_malloc_lock();
   17.12     return ret;
   17.13   }
   17.14  
   17.15 @@ -354,9 +354,9 @@
   17.16  void
   17.17  PR_WL__free( void *ptrToFree )
   17.18   {
   17.19 -   PR_int__get_master_lock();
   17.20 +   PR_int__get_malloc_lock();
   17.21     PR_int__free( ptrToFree );
   17.22 -   PR_int__release_master_lock();
   17.23 +   PR_int__release_malloc_lock();
   17.24   }
   17.25  
   17.26  /*
    18.1 --- a/Services_Offered_by_PR/Services_Language/PRServ.h	Thu Sep 05 18:05:11 2013 -0700
    18.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ.h	Thu Sep 05 18:08:14 2013 -0700
    18.3 @@ -15,7 +15,14 @@
    18.4  
    18.5  
    18.6  //===========================================================================
    18.7 -   //uniquely identifies PRServ -- should be a jenkins char-hash of "PRServ" to int32
    18.8 +
    18.9 +
   18.10 +#define PRServ__malloc( numBytes, callingSlave ) PR_App__malloc( numBytes, callingSlave)
   18.11 +
   18.12 +#define PRServ__free(ptrToFree, callingSlave ) PR_App__free( ptrToFree, callingSlave )
   18.13 +
   18.14 +
   18.15 +//uniquely identifies PRServ -- should be a jenkins char-hash of "PRServ" to int32
   18.16  #define PRServ_MAGIC_NUMBER 0000000001
   18.17  
   18.18  #define NUM_STRUCS_IN_LANG_ENV 1000
    19.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_SS.c	Thu Sep 05 18:05:11 2013 -0700
    19.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_SS.c	Thu Sep 05 18:08:14 2013 -0700
    19.3 @@ -12,7 +12,7 @@
    19.4  #include "Hash_impl/PrivateHash.h"
    19.5  
    19.6  #include "PRServ.h"
    19.7 -#include "PR_impl/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h"
    19.8 +//#include "PR_impl/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h"
    19.9  //==========================================================================
   19.10  
   19.11