Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff MasterLoop.c @ 209:0c83ea8adefc
Close to compilable version of common_ancestor -- still includes HW dep stuff
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Sun, 04 Mar 2012 14:26:35 -0800 |
| parents | eaf7e4c58c9e |
| children | a18539c0bc37 |
line diff
1.1 --- a/MasterLoop.c Wed Feb 22 11:39:12 2012 -0800 1.2 +++ b/MasterLoop.c Sun Mar 04 14:26:35 2012 -0800 1.3 @@ -10,13 +10,12 @@ 1.4 #include <stddef.h> 1.5 1.6 #include "VMS.h" 1.7 -#include "ProcrContext.h" 1.8 1.9 1.10 //=========================================================================== 1.11 void inline 1.12 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, 1.13 - SlaveVP *masterPr ); 1.14 + SlaveVP *masterVP ); 1.15 1.16 //=========================================================================== 1.17 1.18 @@ -27,13 +26,13 @@ 1.19 *Polls each sched slot exactly once, hands any requests made by a newly 1.20 * done slave to the "request handler" plug-in function 1.21 * 1.22 - *Any slots that need a virt procr assigned are given to the "schedule" 1.23 - * plug-in function, which tries to assign a virt procr (slave) to it. 1.24 + *Any slots that need a Slv assigned are given to the "schedule" 1.25 + * plug-in function, which tries to assign a Slv (slave) to it. 1.26 * 1.27 *When all slots needing a processor have been given to the schedule plug-in, 1.28 - * a fraction of the procrs successfully scheduled are put into the 1.29 + * a fraction of the slaves successfully scheduled are put into the 1.30 * work queue, then a continuation of this function is put in, then the rest 1.31 - * of the virt procrs that were successfully scheduled. 1.32 + * of the Slvs that were successfully scheduled. 1.33 * 1.34 *The first thing the continuation does is busy-wait until the previous 1.35 * animation completes. This is because an (unlikely) continuation may 1.36 @@ -46,7 +45,7 @@ 1.37 * start running gets it and does all the stuff for a newly born -- 1.38 * from then on, will be doing continuation, but do suspension self 1.39 * directly at end of master loop 1.40 - *So VMS__init just births the master virtual processor same way it births 1.41 + *So VMS_WL__init just births the master virtual processor same way it births 1.42 * all the others -- then does any extra setup needed and puts it into the 1.43 * work queue. 1.44 *However means have to make masterEnv a global static volatile the same way 1.45 @@ -65,36 +64,36 @@ 1.46 *At this point, the masterLoop does not write itself into the queue anymore, 1.47 * instead, the coreLoop acquires the masterLock when it has nothing to 1.48 * animate, and then animates its own masterLoop. However, still try to put 1.49 - * several AppVPs into the queue to amortize the startup cost of switching 1.50 + * several AppSlvs into the queue to amortize the startup cost of switching 1.51 * to the MasterVP. Note, don't have to worry about latency of requests much 1.52 * because most requests generate work for same core -- only latency issue 1.53 * is case when other cores starved and one core's requests generate work 1.54 * for them -- so keep max in queue to 3 or 4.. 1.55 */ 1.56 -void masterLoop( void *initData, SlaveVP *animatingPr ) 1.57 +void masterLoop( void *initData, SlaveVP *animatingSlv ) 1.58 { 1.59 int32 slotIdx, numSlotsFilled; 1.60 - SlaveVP *schedVirtPr; 1.61 + SlaveVP *schedSlaveVP; 1.62 SchedSlot *currSlot, **schedSlots; 1.63 MasterEnv *masterEnv; 1.64 VMSQueueStruc *readyToAnimateQ; 1.65 1.66 - Sched_Assigner slaveScheduler; 1.67 + Sched_Assigner slaveAssigner; 1.68 RequestHandler requestHandler; 1.69 void *semanticEnv; 1.70 1.71 int32 thisCoresIdx; 1.72 - SlaveVP *masterPr; 1.73 - volatile SlaveVP *volatileMasterPr; 1.74 + SlaveVP *masterVP; 1.75 + volatile SlaveVP *volatileMasterVP; 1.76 1.77 - volatileMasterPr = animatingPr; 1.78 - masterPr = (SlaveVP*)volatileMasterPr; //used to force re-define after jmp 1.79 + volatileMasterVP = animatingSlv; 1.80 + masterVP = (SlaveVP*)volatileMasterVP; //used to force re-define after jmp 1.81 1.82 //First animation of each MasterVP will in turn animate this part 1.83 - // of setup code.. (VP creator sets up the stack as if this function 1.84 + // of setup code.. (Slv creator sets up the stack as if this function 1.85 // was called normally, but actually get here by jmp) 1.86 //So, setup values about stack ptr, jmp pt and all that 1.87 - //masterPr->resumeInstrPtr = &&masterLoopStartPt; 1.88 + //masterVP->resumeInstrPtr = &&masterLoopStartPt; 1.89 1.90 1.91 //Note, got rid of writing the stack and frame ptr up here, because 1.92 @@ -108,25 +107,18 @@ 1.93 //masterLoopStartPt: 1.94 while(1){ 1.95 1.96 - //============================= MEASUREMENT STUFF ======================== 1.97 - #ifdef MEAS__TIME_MASTER 1.98 - //Total Master time includes one coreloop time -- just assume the core 1.99 - // loop time is same for Master as for AppVPs, even though it may be 1.100 - // smaller due to higher predictability of the fixed jmp. 1.101 - saveLowTimeStampCountInto( masterPr->startMasterTSCLow ); 1.102 - #endif 1.103 - //======================================================================== 1.104 + MEAS__Capture_Pre_Master_Point 1.105 1.106 masterEnv = (MasterEnv*)_VMSMasterEnv; 1.107 1.108 //GCC may optimize so doesn't always re-define from frame-storage 1.109 - masterPr = (SlaveVP*)volatileMasterPr; //just to make sure after jmp 1.110 - thisCoresIdx = masterPr->coreAnimatedBy; 1.111 + masterVP = (SlaveVP*)volatileMasterVP; //just to make sure after jmp 1.112 + thisCoresIdx = masterVP->coreAnimatedBy; 1.113 readyToAnimateQ = masterEnv->readyToAnimateQs[thisCoresIdx]; 1.114 schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; 1.115 1.116 requestHandler = masterEnv->requestHandler; 1.117 - slaveScheduler = masterEnv->slaveSchedAssigner; 1.118 + slaveAssigner = masterEnv->slaveAssigner; 1.119 semanticEnv = masterEnv->semanticEnv; 1.120 1.121 1.122 @@ -139,18 +131,18 @@ 1.123 if( currSlot->workIsDone ) 1.124 { 1.125 currSlot->workIsDone = FALSE; 1.126 - currSlot->needsProcrAssigned = TRUE; 1.127 + currSlot->needsSlaveAssigned = TRUE; 1.128 1.129 //process requests from slave to master 1.130 //====================== MEASUREMENT STUFF =================== 1.131 - #ifdef MEAS__TIME_PLUGIN 1.132 + #ifdef MEAS__TURN_ON_PLUGIN_MEAS 1.133 int32 startStamp1, endStamp1; 1.134 saveLowTimeStampCountInto( startStamp1 ); 1.135 #endif 1.136 //============================================================ 1.137 - (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv ); 1.138 + (*requestHandler)( currSlot->slaveAssignedToSlot, semanticEnv ); 1.139 //====================== MEASUREMENT STUFF =================== 1.140 - #ifdef MEAS__TIME_PLUGIN 1.141 + #ifdef MEAS__TURN_ON_PLUGIN_MEAS 1.142 saveLowTimeStampCountInto( endStamp1 ); 1.143 addIntervalToHist( startStamp1, endStamp1, 1.144 _VMSMasterEnv->reqHdlrLowTimeHist ); 1.145 @@ -159,18 +151,18 @@ 1.146 #endif 1.147 //============================================================ 1.148 } 1.149 - if( currSlot->needsProcrAssigned ) 1.150 - { //give slot a new virt procr 1.151 - schedVirtPr = 1.152 - (*slaveScheduler)( semanticEnv, thisCoresIdx ); 1.153 + if( currSlot->needsSlaveAssigned ) 1.154 + { //give slot a new Slv 1.155 + schedSlaveVP = 1.156 + (*slaveAssigner)( semanticEnv, thisCoresIdx ); 1.157 1.158 - if( schedVirtPr != NULL ) 1.159 - { currSlot->procrAssignedToSlot = schedVirtPr; 1.160 - schedVirtPr->schedSlot = currSlot; 1.161 - currSlot->needsProcrAssigned = FALSE; 1.162 + if( schedSlaveVP != NULL ) 1.163 + { currSlot->slaveAssignedToSlot = schedSlaveVP; 1.164 + schedSlaveVP->schedSlot = currSlot; 1.165 + currSlot->needsSlaveAssigned = FALSE; 1.166 numSlotsFilled += 1; 1.167 1.168 - writeVMSQ( schedVirtPr, readyToAnimateQ ); 1.169 + writeVMSQ( schedSlaveVP, readyToAnimateQ ); 1.170 } 1.171 } 1.172 } 1.173 @@ -179,16 +171,13 @@ 1.174 #ifdef USE_WORK_STEALING 1.175 //If no slots filled, means no more work, look for work to steal. 1.176 if( numSlotsFilled == 0 ) 1.177 - { gateProtected_stealWorkInto( currSlot, readyToAnimateQ, masterPr ); 1.178 + { gateProtected_stealWorkInto( currSlot, readyToAnimateQ, masterVP ); 1.179 } 1.180 #endif 1.181 1.182 + MEAS__Capture_Post_Master_Point; 1.183 1.184 - #ifdef MEAS__TIME_MASTER 1.185 - saveLowTimeStampCountInto( masterPr->endMasterTSCLow ); 1.186 - #endif 1.187 - 1.188 - masterSwitchToCoreLoop(animatingPr); 1.189 + masterSwitchToCoreLoop(animatingSlv); 1.190 flushRegisters(); 1.191 }//MasterLoop 1.192 1.193 @@ -202,14 +191,14 @@ 1.194 */ 1.195 void inline 1.196 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, 1.197 - SlaveVP *masterPr ) 1.198 + SlaveVP *masterVP ) 1.199 { 1.200 - SlaveVP *stolenPr; 1.201 + SlaveVP *stolenSlv; 1.202 int32 coreIdx, i; 1.203 VMSQueueStruc *currQ; 1.204 1.205 - stolenPr = NULL; 1.206 - coreIdx = masterPr->coreAnimatedBy; 1.207 + stolenSlv = NULL; 1.208 + coreIdx = masterVP->coreAnimatedBy; 1.209 for( i = 0; i < NUM_CORES -1; i++ ) 1.210 { 1.211 if( coreIdx >= NUM_CORES -1 ) 1.212 @@ -220,17 +209,17 @@ 1.213 } 1.214 currQ = _VMSMasterEnv->readyToAnimateQs[coreIdx]; 1.215 if( numInVMSQ( currQ ) > 0 ) 1.216 - { stolenPr = readVMSQ (currQ ); 1.217 + { stolenSlv = readVMSQ (currQ ); 1.218 break; 1.219 } 1.220 } 1.221 1.222 - if( stolenPr != NULL ) 1.223 - { currSlot->procrAssignedToSlot = stolenPr; 1.224 - stolenPr->schedSlot = currSlot; 1.225 - currSlot->needsProcrAssigned = FALSE; 1.226 + if( stolenSlv != NULL ) 1.227 + { currSlot->slaveAssignedToSlot = stolenSlv; 1.228 + stolenSlv->schedSlot = currSlot; 1.229 + currSlot->needsSlaveAssigned = FALSE; 1.230 1.231 - writeVMSQ( stolenPr, readyToAnimateQ ); 1.232 + writeVMSQ( stolenSlv, readyToAnimateQ ); 1.233 } 1.234 } 1.235 1.236 @@ -306,9 +295,9 @@ 1.237 void inline 1.238 gateProtected_stealWorkInto( SchedSlot *currSlot, 1.239 VMSQueueStruc *myReadyToAnimateQ, 1.240 - SlaveVP *masterPr ) 1.241 + SlaveVP *masterVP ) 1.242 { 1.243 - SlaveVP *stolenPr; 1.244 + SlaveVP *stolenSlv; 1.245 int32 coreIdx, i, haveAVictim, gotLock; 1.246 VMSQueueStruc *victimsQ; 1.247 1.248 @@ -319,7 +308,7 @@ 1.249 1.250 //see if any other cores have work available to steal 1.251 haveAVictim = FALSE; 1.252 - coreIdx = masterPr->coreAnimatedBy; 1.253 + coreIdx = masterVP->coreAnimatedBy; 1.254 for( i = 0; i < NUM_CORES -1; i++ ) 1.255 { 1.256 if( coreIdx >= NUM_CORES -1 ) 1.257 @@ -354,18 +343,18 @@ 1.258 coreMightBeInProtected = FALSE; 1.259 } 1.260 1.261 - stolenPr = readVMSQ ( victimsQ ); 1.262 + stolenSlv = readVMSQ ( victimsQ ); 1.263 1.264 vicGate->gateClosed = FALSE; 1.265 //======= End Gate-protection ======= 1.266 1.267 1.268 - if( stolenPr != NULL ) //victim could have been in protected and taken 1.269 - { currSlot->procrAssignedToSlot = stolenPr; 1.270 - stolenPr->schedSlot = currSlot; 1.271 - currSlot->needsProcrAssigned = FALSE; 1.272 + if( stolenSlv != NULL ) //victim could have been in protected and taken 1.273 + { currSlot->slaveAssignedToSlot = stolenSlv; 1.274 + stolenSlv->schedSlot = currSlot; 1.275 + currSlot->needsSlaveAssigned = FALSE; 1.276 1.277 - writeVMSQ( stolenPr, myReadyToAnimateQ ); 1.278 + writeVMSQ( stolenSlv, myReadyToAnimateQ ); 1.279 } 1.280 1.281 //unlock the work stealing lock
