Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison MasterLoop.c @ 218:82f7defac851
Added backoff to core loop, cleaned up core loop code, cleaned comments
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Sat, 10 Mar 2012 21:48:53 -0800 |
| parents | a18539c0bc37 |
| children |
comparison
equal
deleted
inserted
replaced
| 60:548ac2b6791d | 62:adb18b284638 |
|---|---|
| 39 * sneak through queue before previous continuation is done putting second | 39 * sneak through queue before previous continuation is done putting second |
| 40 * part of scheduled slaves in, which is the only race condition. | 40 * part of scheduled slaves in, which is the only race condition. |
| 41 * | 41 * |
| 42 */ | 42 */ |
| 43 | 43 |
| 44 /*May 29, 2010 -- birth a Master during init so that first core loop to | 44 /*May 29, 2010 -- birth a Master during init so that first core controller to |
| 45 * start running gets it and does all the stuff for a newly born -- | 45 * start running gets it and does all the stuff for a newly born -- |
| 46 * from then on, will be doing continuation, but do suspension self | 46 * from then on, will be doing continuation, but do suspension self |
| 47 * directly at end of master loop | 47 * directly at end of master loop |
| 48 *So VMS_WL__init just births the master virtual processor same way it births | 48 *So VMS_WL__init just births the master virtual processor same way it births |
| 49 * all the others -- then does any extra setup needed and puts it into the | 49 * all the others -- then does any extra setup needed and puts it into the |
| 50 * work queue. | 50 * work queue. |
| 51 *However means have to make masterEnv a global static volatile the same way | 51 *However means have to make masterEnv a global static volatile the same way |
| 52 * did with readyToAnimateQ in core loop. -- for performance, put the | 52 * did with readyToAnimateQ in core controller. -- for performance, put the |
| 53 * jump to the core loop directly in here, and have it directly jump back. | 53 * jump to the core controller directly in here, and have it directly jump back. |
| 54 * | 54 * |
| 55 * | 55 * |
| 56 *Aug 18, 2010 -- Going to a separate MasterVP for each core, to see if this | 56 *Aug 18, 2010 -- Going to a separate MasterVP for each core, to see if this |
| 57 * avoids the suspected bug in the system stack that causes bizarre faults | 57 * avoids the suspected bug in the system stack that causes bizarre faults |
| 58 * at random places in the system code. | 58 * at random places in the system code. |
| 60 *So, this function is coupled to each of the MasterVPs, -- meaning this | 60 *So, this function is coupled to each of the MasterVPs, -- meaning this |
| 61 * function can't rely on a particular stack and frame -- each MasterVP that | 61 * function can't rely on a particular stack and frame -- each MasterVP that |
| 62 * animates this function has a different one. | 62 * animates this function has a different one. |
| 63 * | 63 * |
| 64 *At this point, the masterLoop does not write itself into the queue anymore, | 64 *At this point, the masterLoop does not write itself into the queue anymore, |
| 65 * instead, the coreLoop acquires the masterLock when it has nothing to | 65 * instead, the coreCtlr acquires the masterLock when it has nothing to |
| 66 * animate, and then animates its own masterLoop. However, still try to put | 66 * animate, and then animates its own masterLoop. However, still try to put |
| 67 * several AppSlvs into the queue to amortize the startup cost of switching | 67 * several AppSlvs into the queue to amortize the startup cost of switching |
| 68 * to the MasterVP. Note, don't have to worry about latency of requests much | 68 * to the MasterVP. Note, don't have to worry about latency of requests much |
| 69 * because most requests generate work for same core -- only latency issue | 69 * because most requests generate work for same core -- only latency issue |
| 70 * is case when other cores starved and one core's requests generate work | 70 * is case when other cores starved and one core's requests generate work |
| 162 } | 162 } |
| 163 #endif | 163 #endif |
| 164 | 164 |
| 165 MEAS__Capture_Post_Master_Point; | 165 MEAS__Capture_Post_Master_Point; |
| 166 | 166 |
| 167 masterSwitchToCoreLoop(animatingSlv); | 167 masterSwitchToCoreCtlr(animatingSlv); |
| 168 flushRegisters(); | 168 flushRegisters(); |
| 169 }//MasterLoop | 169 }//MasterLoop |
| 170 | 170 |
| 171 | 171 |
| 172 } | 172 } |
| 258 * in a system with little work, it doesn't matter. | 258 * in a system with little work, it doesn't matter. |
| 259 * | 259 * |
| 260 *Note, have single-reader, single-writer pattern for all variables used to | 260 *Note, have single-reader, single-writer pattern for all variables used to |
| 261 * communicate between stealer and victims | 261 * communicate between stealer and victims |
| 262 * | 262 * |
| 263 *So, scan the queues of the core loops, until find non-empty. Each core | 263 *So, scan the queues of the core controllers, until find non-empty. Each core |
| 264 * has its own list that it scans. The list goes in order from closest to | 264 * has its own list that it scans. The list goes in order from closest to |
| 265 * furthest core, so it steals first from close cores. Later can add | 265 * furthest core, so it steals first from close cores. Later can add |
| 266 * taking info from the app about overlapping footprints, and scan all the | 266 * taking info from the app about overlapping footprints, and scan all the |
| 267 * others then choose work with the most footprint overlap with the contents | 267 * others then choose work with the most footprint overlap with the contents |
| 268 * of this core's cache. | 268 * of this core's cache. |
| 314 if( !haveAVictim ) return; //no work to steal, exit | 314 if( !haveAVictim ) return; //no work to steal, exit |
| 315 | 315 |
| 316 //have a victim core, now get the stealer-lock | 316 //have a victim core, now get the stealer-lock |
| 317 gotLock =__sync_bool_compare_and_swap( &(_VMSMasterEnv->workStealingLock), | 317 gotLock =__sync_bool_compare_and_swap( &(_VMSMasterEnv->workStealingLock), |
| 318 UNLOCKED, LOCKED ); | 318 UNLOCKED, LOCKED ); |
| 319 if( !gotLock ) return; //go back to core loop, which will re-start master | 319 if( !gotLock ) return; //go back to core controller, which will re-start master |
| 320 | 320 |
| 321 | 321 |
| 322 //====== Start Gate-protection ======= | 322 //====== Start Gate-protection ======= |
| 323 vicGate->gateClosed = TRUE; | 323 vicGate->gateClosed = TRUE; |
| 324 coreMightBeInProtected= vicGate->preGateProgress != vicGate->exitProgress; | 324 coreMightBeInProtected= vicGate->preGateProgress != vicGate->exitProgress; |
