Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 276:1d7ea1b0f176 Dev_ML
Dev_ML Working in sequential mode
author | Sean Halle <seanhalle@yahoo.com> |
---|---|
date | Mon, 04 Mar 2013 00:40:38 -0800 |
parents | 7ab0d5bf16cb |
children | 2fc69e6c14ea |
files | AnimationMaster.c CoreController.c PR.c PR__SS.c PR__WL.h PR__int.c Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Services_Offered_by_PR/Services_Language/PRServ_SS.c |
diffstat | 8 files changed, 85 insertions(+), 62 deletions(-) [+] |
line diff
1.1 --- a/AnimationMaster.c Sat Mar 02 09:54:19 2013 -0800 1.2 +++ b/AnimationMaster.c Mon Mar 04 00:40:38 2013 -0800 1.3 @@ -516,6 +516,8 @@ 1.4 (*protoLangEnv->shutdownHdlr)( langEnv ); 1.5 1.6 PR_int__remove_lang_env_from_process_and_free( langEnv ); //removes from process and frees 1.7 + 1.8 + PR_PI__resume_slave_in_PRServ( requestingSlv ); 1.9 } 1.10 1.11
2.1 --- a/CoreController.c Sat Mar 02 09:54:19 2013 -0800 2.2 +++ b/CoreController.c Mon Mar 04 00:40:38 2013 -0800 2.3 @@ -369,7 +369,9 @@ 2.4 if( numRepetitionsWithNoWork > NUM_REPS_W_NO_WORK_BEFORE_BACKOFF) 2.5 doBackoff_for_TooLongWithNoWork( numRepetitionsWithNoWork, &seed1, &seed2 ); 2.6 if( numRepetitionsWithNoWork > NUM_REPS_W_NO_WORK_BEFORE_YIELD ) 2.7 - { numRepetitionsWithNoWork = 0; pthread_yield(); } 2.8 + { //This is sequential mode.. just return 2.9 + return; 2.10 + } 2.11 2.12 2.13 //Try to get the lock
3.1 --- a/PR.c Sat Mar 02 09:54:19 2013 -0800 3.2 +++ b/PR.c Mon Mar 04 00:40:38 2013 -0800 3.3 @@ -10,7 +10,6 @@ 3.4 #include <malloc.h> 3.5 #include <inttypes.h> 3.6 #include <sys/time.h> 3.7 -#include <pthread.h> 3.8 3.9 #include "PR.h" 3.10 3.11 @@ -117,7 +116,8 @@ 3.12 process->langEnvs = langEnvs; 3.13 process->protoLangEnvsList = langEnvsList; 3.14 process->numLangEnvs = 0; 3.15 - 3.16 + process->hasWaitingToEnd = FALSE; 3.17 + 3.18 //A Process starts with one slave, the seed slave 3.19 seedSlv = PR_int__create_slaveVP( seed_Fn, seedData, process ); 3.20 seedSlv->typeOfVP = SeedSlv; 3.21 @@ -212,14 +212,23 @@ 3.22 } 3.23 3.24 3.25 +/*This should only be called from main. It makes the OS thread that is animating 3.26 + * main to suspend until the process completes shutdown. 3.27 + */ 3.28 void 3.29 PR__wait_for_process_to_end( PRProcess *process ) 3.30 { 3.31 + process->hasWaitingToEnd = TRUE; 3.32 + 3.33 #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 3.34 // call the one and only core ctlr (sequential version), in the main thread. 3.35 - coreCtlr_Seq( NULL ); 3.36 - flushRegisters(); //Not sure why here, but leaving to be safe 3.37 - 3.38 + if( process->executionIsComplete ) 3.39 + return; 3.40 + else 3.41 + { coreCtlr_Seq( NULL ); 3.42 + flushRegisters(); //Not sure why here, but leaving to be safe 3.43 + process->executionIsComplete = TRUE; 3.44 + } 3.45 #else 3.46 //First get the "ACK" lock, then do normal wait for signal, then release 3.47 // ACK lock, to let end-process know it can free the process struct 3.48 @@ -244,6 +253,11 @@ 3.49 void 3.50 PR__wait_for_all_activity_to_end() 3.51 { 3.52 + #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 3.53 + //In sequential mode, can't reach this call unless all activity has 3.54 + // already completed, so just return. 3.55 + return; 3.56 + #else 3.57 pthread_mutex_lock( &(_PRTopEnv->activityDoneLock) ); 3.58 while( !(_PRTopEnv->allActivityIsDone) ) 3.59 { 3.60 @@ -251,6 +265,7 @@ 3.61 &(_PRTopEnv->activityDoneLock) ); 3.62 } 3.63 pthread_mutex_unlock( &(_PRTopEnv->activityDoneLock) ); 3.64 + #endif 3.65 } 3.66 3.67
4.1 --- a/PR__SS.c Sat Mar 02 09:54:19 2013 -0800 4.2 +++ b/PR__SS.c Mon Mar 04 00:40:38 2013 -0800 4.3 @@ -72,15 +72,7 @@ 4.4 //Make the animation slots and similar per-core structs.. 4.5 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 4.6 { 4.7 - //readyToAnimateQs[ coreIdx ] = makePRQ(); 4.8 - 4.9 -/* //Q: should give masterVP core-specific info as its init data? 4.10 - Don't have masterVPs anymore -- the pinned pthread takes that role 4.11 - masterVPs[ coreIdx ] = PR_int__create_slaveVP_helper( (TopLevelFnPtr)&animationMaster, (void*)_PRTopEnv ); 4.12 - masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; 4.13 - masterVPs[ coreIdx ]->typeOfVP = Master; 4.14 - */ 4.15 - allAnimSlots[ coreIdx ] = PR_SS__create_anim_slots( coreIdx ); //makes for one core 4.16 +// allAnimSlots[ coreIdx ] = PR_SS__create_anim_slots( coreIdx ); //makes for one core 4.17 } 4.18 4.19 //For each animation slot, there is an idle slave, and an initial 4.20 @@ -91,23 +83,25 @@ 4.21 for( coreNum = 0; coreNum < NUM_CORES; coreNum++ ) 4.22 { //langEnv->coreIsDone[coreNum] = FALSE; //use during shutdown 4.23 //Still have multiple slots -- left over from prev incarnation 4.24 - for( slotNum = 0; slotNum < NUM_ANIM_SLOTS; ++slotNum ) 4.25 - { idleSlv = PR_int__create_slaveVP_helper( &idle_fn, NULL ); 4.26 - idleSlv->coreAnimatedBy = coreNum; 4.27 - idleSlv->typeOfVP = IdleVP; 4.28 - idleSlv->animSlotAssignedTo = 4.29 - _PRTopEnv->allAnimSlots[coreNum][slotNum]; 4.30 - _PRTopEnv->idleSlv[coreNum][slotNum] = idleSlv; 4.31 + allAnimSlots[ coreNum ] = PR_SS__create_anim_slots( coreNum ); //makes for one core 4.32 + 4.33 + slotNum = 0; //quick fix -- remove last vestiges of multiple slots per core 4.34 + idleSlv = PR_int__create_slaveVP_helper( &idle_fn, NULL ); 4.35 + idleSlv->coreAnimatedBy = coreNum; 4.36 + idleSlv->typeOfVP = IdleVP; 4.37 + idleSlv->animSlotAssignedTo = allAnimSlots[coreNum][slotNum]; 4.38 + //start with all slots filled by the idle slaves 4.39 + (allAnimSlots[coreNum][slotNum])->slaveAssignedToSlot = idleSlv; 4.40 + _PRTopEnv->idleSlv[coreNum][slotNum] = idleSlv; 4.41 4.42 4.43 - slotTaskSlv = PR_int__create_slot_slave( ); 4.44 - slotTaskSlv->coreAnimatedBy = coreNum; 4.45 - slotTaskSlv->animSlotAssignedTo = 4.46 - _PRTopEnv->allAnimSlots[coreNum][slotNum]; 4.47 + slotTaskSlv = PR_int__create_slot_slave( ); 4.48 + slotTaskSlv->coreAnimatedBy = coreNum; 4.49 + slotTaskSlv->animSlotAssignedTo = allAnimSlots[coreNum][slotNum]; 4.50 4.51 - slotTaskSlv->typeOfVP = SlotTaskSlv; 4.52 - _PRTopEnv->slotTaskSlvs[coreNum][slotNum] = slotTaskSlv; 4.53 - } 4.54 + slotTaskSlv->typeOfVP = SlotTaskSlv; 4.55 + _PRTopEnv->slotTaskSlvs[coreNum][slotNum] = slotTaskSlv; 4.56 + 4.57 } 4.58 4.59 _PRTopEnv->slaveRecycleQ = makePRQ(); 4.60 @@ -251,26 +245,26 @@ 4.61 */ 4.62 void 4.63 PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ) 4.64 - { PRLangEnv *langEnv; 4.65 + { PRLangEnv *protoLangEnv; 4.66 4.67 - langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.68 - langEnv->workAssigner = assigner; 4.69 + protoLangEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.70 + protoLangEnv->workAssigner = assigner; 4.71 } 4.72 void 4.73 PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 4.74 int32 magicNum ) 4.75 - { PRLangEnv *langEnv; 4.76 + { PRLangEnv *protoLangEnv; 4.77 4.78 - langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.79 - langEnv->shutdownHdlr = shutdownHdlr; 4.80 + protoLangEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.81 + protoLangEnv->shutdownHdlr = shutdownHdlr; 4.82 } 4.83 void 4.84 PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 4.85 SlaveVP *seedVP, int32 magicNum ) 4.86 - { PRLangEnv *langEnv; 4.87 + { PRLangEnv *protoLangEnv; 4.88 4.89 - langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.90 - langEnv->langDataCreator = langDataCreator; 4.91 + protoLangEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.92 + protoLangEnv->langDataCreator = langDataCreator; 4.93 } 4.94 void 4.95 PR_SS__register_lang_meta_task_creator( LangMetaTaskCreator langMetaTaskCreator, 4.96 @@ -283,18 +277,18 @@ 4.97 void 4.98 PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 4.99 int32 magicNum ) 4.100 - { PRLangEnv *langEnv; 4.101 + { PRLangEnv *protoLangEnv; 4.102 4.103 - langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.104 - langEnv->makeSlaveReadyFn = fn; 4.105 + protoLangEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.106 + protoLangEnv->makeSlaveReadyFn = fn; 4.107 } 4.108 void 4.109 PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 4.110 int32 magicNum ) 4.111 - { PRLangEnv *langEnv; 4.112 + { PRLangEnv *protoLangEnv; 4.113 4.114 - langEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.115 - langEnv->makeTaskReadyFn = fn; 4.116 + protoLangEnv = PR_SS__give_proto_lang_env_for_slave( seedVP, magicNum ); 4.117 + protoLangEnv->makeTaskReadyFn = fn; 4.118 } 4.119 4.120 //======== 4.121 @@ -331,12 +325,12 @@ 4.122 //Then free the lang env 4.123 PRLangEnv *protoLangEnv; 4.124 for( i = 0; i < process->numLangEnvs; i++ ) 4.125 - { protoLangEnv = PR_int__give_proto_lang_env(process->protoLangEnvsList[i]); 4.126 + { protoLangEnv = process->protoLangEnvsList[i]; 4.127 //The lang shutdowns should free any slaves or tasks in the langEnv 4.128 (*protoLangEnv->shutdownHdlr)(&(protoLangEnv[1])); 4.129 - PR_int__free( protoLangEnv ); 4.130 + PR_int__free( protoLangEnv ); //don't need to remove from process! 4.131 } 4.132 - PR_int__free( process->protoLangEnvsList ); //list array 4.133 + PR_int__free( process->protoLangEnvsList ); //array of Envs empty so free it 4.134 PR_int__free( &(((int32 *)process->langEnvs)[-1]) ); //the collection array 4.135 4.136 //any slaves from this process still in slots will finish executing, but 4.137 @@ -360,15 +354,25 @@ 4.138 //cause resume of "PR__wait_for_process_to_end()" call 4.139 if( process->hasWaitingToEnd ) 4.140 { 4.141 + #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 4.142 + process->executionIsComplete = TRUE; 4.143 + PR_int__free(process); 4.144 + //The "wait for process to end" call started the PR activity that 4.145 + // happens inside that process. That leads to here, running inside the 4.146 + // master.. so just return, and let the core ctlr detect no work and 4.147 + // return. 4.148 + return; 4.149 + #else 4.150 pthread_mutex_lock( &(process->doneLock) ); 4.151 process->executionIsComplete = TRUE; 4.152 pthread_mutex_unlock( &(process->doneLock) ); 4.153 - pthread_cond_broadcast( &(process->doneCond) ); 4.154 - //now wait for woken waiter to Ack, then free the process struct 4.155 - pthread_mutex_lock( &(process->doneAckLock) ); //BUG:? may be a race 4.156 - pthread_mutex_unlock( &(process->doneAckLock) ); 4.157 - PR_int__free(process); 4.158 - } 4.159 + pthread_cond_broadcast( &(process->doneCond) ); 4.160 + //now wait for woken waiter to Ack, then free the process struct 4.161 + pthread_mutex_lock( &(process->doneAckLock) ); //BUG:? may be a race 4.162 + pthread_mutex_unlock( &(process->doneAckLock) ); 4.163 + PR_int__free(process); 4.164 + #endif 4.165 + } 4.166 //if no more processes, cause resume of "PR__wait_for_all_activity_to_end" 4.167 if( _PRTopEnv->numProcesses == 0) 4.168 {
5.1 --- a/PR__WL.h Sat Mar 02 09:54:19 2013 -0800 5.2 +++ b/PR__WL.h Mon Mar 04 00:40:38 2013 -0800 5.3 @@ -53,7 +53,6 @@ 5.4 5.5 void 5.6 PR__wait_for_process_to_end( PRProcess *process ); 5.7 -fixme; //process->hasWaitingToEnd 5.8 5.9 void 5.10 PR__wait_for_all_activity_to_end();
6.1 --- a/PR__int.c Sat Mar 02 09:54:19 2013 -0800 6.2 +++ b/PR__int.c Mon Mar 04 00:40:38 2013 -0800 6.3 @@ -359,6 +359,7 @@ 6.4 idx = protoLangEnv->idxInProcess; 6.5 count = (process->numLangEnvs - idx) * sizeof(PRLangEnv *);//idx starts at 0 6.6 memmove( &(langEnvsList[idx]), &(langEnvsList[idx+1]), count); 6.7 + process->numLangEnvs -= 1; 6.8 6.9 PR_int__free( protoLangEnv ); 6.10 }
7.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Sat Mar 02 09:54:19 2013 -0800 7.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Mon Mar 04 00:40:38 2013 -0800 7.3 @@ -320,11 +320,11 @@ 7.4 } 7.5 7.6 void 7.7 -PRServ__handleDissipateSeed(void *langReq, SlaveVP *seedSlv, VSsLangEnv *langEnv ) 7.8 +PRServ__handleDissipateSeed(void *langReq, SlaveVP *seedSlv, PRServLangEnv *langEnv ) 7.9 { 7.10 7.11 DEBUG__printf1(dbgRqstHdlr,"Dissipate in PRServ %d", 7.12 - requestingSlv->slaveNum); 7.13 + seedSlv->slaveNum); 7.14 //This should only ever be called for the seed slave -- for which there's 7.15 // nothing to do.. 7.16 if( seedSlv->typeOfVP != SeedSlv )
8.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_SS.c Sat Mar 02 09:54:19 2013 -0800 8.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_SS.c Mon Mar 04 00:40:38 2013 -0800 8.3 @@ -12,7 +12,7 @@ 8.4 #include "Hash_impl/PrivateHash.h" 8.5 8.6 #include "PRServ.h" 8.7 -#include "PR_impl/Services_Offered_by_PR/Measurement_and_Stats/PR_MEAS__Counter_Recording.h" 8.8 +#include "PR_impl/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h" 8.9 //========================================================================== 8.10 8.11 8.12 @@ -41,11 +41,11 @@ 8.13 // PR_SS__register_lang_meta_task_creator( &PRServ__create_empty_lang_meta_task_in_slave, seedSlv, PRServ_MAGIC_NUMBER ); 8.14 PR_SS__register_make_slave_ready_fn( &PRServ__resume_slave, seedSlv, PRServ_MAGIC_NUMBER ); 8.15 PR_SS__register_make_task_ready_fn( &PRServ__make_task_ready, seedSlv, PRServ_MAGIC_NUMBER ); 8.16 - 8.17 - #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 8.18 + 8.19 + #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 8.20 _PRTopEnv->counterHandler = &PR_MEAS__counter_handler; 8.21 PR_MEAS__init_counter_data_structs_for_lang( seedSlv, PRServ_MAGIC_NUMBER ); 8.22 - #endif 8.23 + #endif 8.24 8.25 8.26 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit 8.27 @@ -225,8 +225,8 @@ 8.28 freePrivQ( langEnv->fnSingletons[i].waitQ ); 8.29 freePrivQ( langEnv->transactionStrucs[i].waitingVPQ ); 8.30 } 8.31 - 8.32 - PR_int__remove_lang_env_from_process_and_free( langEnv ); 8.33 + //note, PR handles removing the langEnv from the process and freeing 8.34 + // the langEnv chunk of memory 8.35 } 8.36 8.37