Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison MasterLoop.c @ 70:f9b60012fd74
working ucontext version
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 27 May 2011 12:35:40 +0200 |
| parents | 11bfe9d136ed |
| children | efb55f1b5fb9 |
comparison
equal
deleted
inserted
replaced
| 21:da2284d25a80 | 22:2f23630d978a |
|---|---|
| 16 void inline | 16 void inline |
| 17 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, | 17 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, |
| 18 VirtProcr *masterPr ); | 18 VirtProcr *masterPr ); |
| 19 | 19 |
| 20 //=========================================================================== | 20 //=========================================================================== |
| 21 | |
| 22 | 21 |
| 23 | 22 |
| 24 /*This code is animated by the virtual Master processor. | 23 /*This code is animated by the virtual Master processor. |
| 25 * | 24 * |
| 26 *Polls each sched slot exactly once, hands any requests made by a newly | 25 *Polls each sched slot exactly once, hands any requests made by a newly |
| 82 RequestHandler requestHandler; | 81 RequestHandler requestHandler; |
| 83 void *semanticEnv; | 82 void *semanticEnv; |
| 84 | 83 |
| 85 int32 thisCoresIdx; | 84 int32 thisCoresIdx; |
| 86 VirtProcr *masterPr; | 85 VirtProcr *masterPr; |
| 87 volatile VirtProcr *volatileMasterPr; | |
| 88 | |
| 89 volatileMasterPr = animatingPr; | |
| 90 masterPr = (VirtProcr*)volatileMasterPr; //used to force re-define after jmp | |
| 91 | 86 |
| 92 //First animation of each MasterVP will in turn animate this part | 87 //First animation of each MasterVP will in turn animate this part |
| 93 // of setup code.. (VP creator sets up the stack as if this function | 88 // of setup code.. (VP creator sets up the stack as if this function |
| 94 // was called normally, but actually get here by jmp) | 89 // was called normally, but actually get here by jmp) |
| 95 //So, setup values about stack ptr, jmp pt and all that | 90 //So, setup values about stack ptr, jmp pt and all that |
| 96 masterPr->nextInstrPt = &&masterLoopStartPt; | 91 masterPr = animatingPr; //just to make sure after jmp |
| 97 | 92 |
| 98 | 93 |
| 99 //Note, got rid of writing the stack and frame ptr up here, because | 94 //Note, got rid of writing the stack and frame ptr up here, because |
| 100 // only one | 95 // only one |
| 101 // core can ever animate a given MasterVP, so don't need to communicate | 96 // core can ever animate a given MasterVP, so don't need to communicate |
| 102 // new frame and stack ptr to the MasterVP storage before a second | 97 // new frame and stack ptr to the MasterVP storage before a second |
| 103 // version of that MasterVP can get animated on a different core. | 98 // version of that MasterVP can get animated on a different core. |
| 104 //Also got rid of the busy-wait. | 99 //Also got rid of the busy-wait. |
| 105 | 100 |
| 106 | 101 masterEnv = (MasterEnv*)_VMSMasterEnv; |
| 107 masterLoopStartPt: | 102 |
| 103 thisCoresIdx = masterPr->coreAnimatedBy; | |
| 104 readyToAnimateQ = masterEnv->readyToAnimateQs[thisCoresIdx]; | |
| 105 schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; | |
| 106 | |
| 107 requestHandler = masterEnv->requestHandler; | |
| 108 slaveScheduler = masterEnv->slaveScheduler; | |
| 109 semanticEnv = masterEnv->semanticEnv; | |
| 110 | |
| 111 | |
| 112 | |
| 113 while(1){ | |
| 114 | |
| 108 //============================= MEASUREMENT STUFF ======================== | 115 //============================= MEASUREMENT STUFF ======================== |
| 109 #ifdef MEAS__TIME_MASTER | 116 #ifdef MEAS__TIME_MASTER |
| 110 //Total Master time includes one coreloop time -- just assume the core | 117 //Total Master time includes one coreloop time -- just assume the core |
| 111 // loop time is same for Master as for AppVPs, even though it may be | 118 // loop time is same for Master as for AppVPs, even though it may be |
| 112 // smaller due to higher predictability of the fixed jmp. | 119 // smaller due to higher predictability of the fixed jmp. |
| 113 saveLowTimeStampCountInto( masterPr->startMasterTSCLow ); | 120 saveLowTimeStampCountInto( masterPr->startMasterTSCLow ); |
| 114 #endif | 121 #endif |
| 115 //======================================================================== | 122 //======================================================================== |
| 116 | 123 |
| 117 masterEnv = (MasterEnv*)_VMSMasterEnv; | 124 //Poll each slot's Done flag |
| 118 | |
| 119 //GCC may optimize so doesn't always re-define from frame-storage | |
| 120 masterPr = (VirtProcr*)volatileMasterPr; //just to make sure after jmp | |
| 121 thisCoresIdx = masterPr->coreAnimatedBy; | |
| 122 readyToAnimateQ = masterEnv->readyToAnimateQs[thisCoresIdx]; | |
| 123 schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; | |
| 124 | |
| 125 requestHandler = masterEnv->requestHandler; | |
| 126 slaveScheduler = masterEnv->slaveScheduler; | |
| 127 semanticEnv = masterEnv->semanticEnv; | |
| 128 | |
| 129 | |
| 130 //Poll each slot's Done flag | |
| 131 numSlotsFilled = 0; | 125 numSlotsFilled = 0; |
| 132 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) | 126 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) |
| 133 { | 127 { |
| 134 currSlot = schedSlots[ slotIdx ]; | 128 currSlot = schedSlots[ slotIdx ]; |
| 135 | 129 |
| 183 | 177 |
| 184 #ifdef MEAS__TIME_MASTER | 178 #ifdef MEAS__TIME_MASTER |
| 185 saveLowTimeStampCountInto( masterPr->endMasterTSCLow ); | 179 saveLowTimeStampCountInto( masterPr->endMasterTSCLow ); |
| 186 #endif | 180 #endif |
| 187 | 181 |
| 188 | 182 //Clear lock |
| 189 | 183 _VMSMasterEnv->masterLock = 0; |
| 190 /* VirtProcr offsets: | 184 |
| 191 * 0xc stackPtr | 185 //Swap to coreLoop |
| 192 * 0x10 framePtr | 186 swapcontext(masterPr->savedVPStatus,masterPr->savedCoreLoopStatus); |
| 193 * 0x14 nextInstrPt | 187 } |
| 194 * 0x1c coreLoopFramePtr | |
| 195 * 0x20 coreLoopStackPtr | |
| 196 * | |
| 197 * _VMSMasterEnv offsets: | |
| 198 * 0x24 coreLoopStartPt | |
| 199 * 0x28 coreLoopEndPt | |
| 200 * 0x30 masterLock | |
| 201 */ | |
| 202 // masterSwitchToCoreLoop( masterPr ) | |
| 203 asm volatile("movl %0, %%ebx; \ | |
| 204 movl %1, %%ecx; \ | |
| 205 movl %%esp, 0x0c(%%ecx); \ | |
| 206 movl %%ebp, 0x10(%%ecx); \ | |
| 207 movl 0x24(%%ebx), %%eax; \ | |
| 208 movl 0x20(%%ecx), %%esp; \ | |
| 209 movl 0x1c(%%ecx), %%ebp; \ | |
| 210 movl $0x0, 0x30(%%ebx); \ | |
| 211 jmp %%eax" \ | |
| 212 /* outputs */ : \ | |
| 213 /* inputs */ : "g"(_VMSMasterEnv), "g"(masterPr) \ | |
| 214 /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ | |
| 215 ); | |
| 216 | 188 |
| 217 } | 189 } |
| 218 | |
| 219 | 190 |
| 220 | 191 |
| 221 /*This has a race condition -- the coreloops are accessing their own queues | 192 /*This has a race condition -- the coreloops are accessing their own queues |
| 222 * at the same time that this work-stealer on a different core is trying to | 193 * at the same time that this work-stealer on a different core is trying to |
| 223 */ | 194 */ |
