comparison MasterLoop.c @ 127:24466227d8bb

bugs fixed, code is now compiling
author Merten Sach <msach@mailbox.tu-berlin.de>
date Wed, 07 Sep 2011 17:45:05 +0200
parents d4c881c7f03a
children dbfc8382d546
comparison
equal deleted inserted replaced
33:e829b6b0438c 34:6934c81bbc98
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 11
12 #include "VMS.h" 12 #include "VMS.h"
13 #include "ProcrContext.h" 13 #include "ProcrContext.h"
14 #include "Master_Request_Handlers.h" 14 #include "inter_VMS_request_handlers.h"
15 15
16 //=========================================================================== 16 //===========================================================================
17 void inline 17 void inline
18 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, 18 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ,
19 VirtProcr *masterPr ); 19 VirtProcr *masterPr);
20
21 void inline
22 handleInterMasterReq( InterMasterReqst *currReq, void *_semEnv,
23 VirtProcr *masterPr);
24
25 void inline
26 handleInterVMSCoreReq( InterVMSCoreReqst *currReq, VirtProcr *masterPr);
20 27
21 //=========================================================================== 28 //===========================================================================
22 29
23 30
24 31
89 masterPr = (VirtProcr*)volatileMasterPr; //used to force re-define after jmp 96 masterPr = (VirtProcr*)volatileMasterPr; //used to force re-define after jmp
90 97
91 //First animation of each MasterVP will in turn animate this part 98 //First animation of each MasterVP will in turn animate this part
92 // of setup code.. (VP creator sets up the stack as if this function 99 // of setup code.. (VP creator sets up the stack as if this function
93 // was called normally, but actually get here by jmp) 100 // was called normally, but actually get here by jmp)
94 //So, setup values about stack ptr, jmp pt and all that
95 //masterPr->nextInstrPt = &&masterLoopStartPt;
96 101
97 //Sept 2011 102 //Sept 2011
98 //Old code jumped directly to this point, but doesn't work on x64 103 //Old code jumped directly to this point, but doesn't work on x64
99 // So, just make this an endless loop, and do assembly function at end 104 // So, just make this an endless loop, and do assembly function at end
100 // that saves its own return addr, then jumps to core_loop. 105 // that saves its own return addr, then jumps to core_loop.
121 requestHandler = masterEnv->requestHandler; 126 requestHandler = masterEnv->requestHandler;
122 slaveScheduler = masterEnv->slaveScheduler; 127 slaveScheduler = masterEnv->slaveScheduler;
123 semanticEnv = masterEnv->semanticEnv; 128 semanticEnv = masterEnv->semanticEnv;
124 129
125 //First, check for requests from other MasterVPs, and handle them 130 //First, check for requests from other MasterVPs, and handle them
126 if( currReq = masterEnv->interMasterRequestsFor[thisCoresIdx] ) 131 InterMasterReqst* currReq = masterEnv->interMasterRequestsFor[thisCoresIdx];
127 { do 132 while(currReq)
128 { handleInterMasterReq( currReq, semanticEnv, masterPr ); 133 {
129 } 134 handleInterMasterReq( currReq, semanticEnv, masterPr );
130 while( currReq = currReq->nextReqst ); 135 currReq = currReq->nextReqst;
131 } 136 }
137
132 //Now, take care of the SlaveVPs 138 //Now, take care of the SlaveVPs
133 //Go through the slots -- if Slave there newly suspended, handle its request 139 //Go through the slots -- if Slave there newly suspended, handle its request
134 // then, either way, ask assigner to fill each slot 140 // then, either way, ask assigner to fill each slot
135 numSlotsFilled = 0; 141 numSlotsFilled = 0;
136 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) 142 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++)
199 * master_loop, others are handed off to the plugin. 205 * master_loop, others are handed off to the plugin.
200 */ 206 */
201 void inline 207 void inline
202 handleInterMasterReq( InterMasterReqst *currReq, void *_semEnv, 208 handleInterMasterReq( InterMasterReqst *currReq, void *_semEnv,
203 VirtProcr *masterPr ) 209 VirtProcr *masterPr )
204 { switch( currReq->reqType ) 210 {
205 { case destVMSCore: 211
206 handleInterVMSCoreReq( (InterVMSCoreReqst *)currReq, masterPr); 212 switch( currReq->reqType )
213 {
214 case destVMSCore:
215 handleInterVMSCoreReq( (InterVMSCoreReqst *)currReq, masterPr);
207 break; 216 break;
208 case destPlugin: 217 case destPlugin:
209 (*interPluginReqHdlr)( ((InterPluginReqst *)currReq)->pluginReq, 218 _VMSMasterEnv->interPluginReqHdlr( ((InterPluginReqst *)currReq)->pluginReq,
210 _semEnv ); 219 _semEnv );
211 break; 220 break;
212 default: 221 default:
213 break; 222 break;
214 } 223 }
215 } 224 }
216 225
217 void inline 226 void inline
218 handleInterVMSReq( InterVMSCoreReqst *currReq, VirtProcr *masterPr ) 227 handleInterVMSCoreReq( InterVMSCoreReqst *currReq, VirtProcr *masterPr )
219 { 228 {
220 switch( currReq->reqType ) 229 switch( currReq->reqType )
221 { 230 {
222 case transfer_free_ptr: handleTransferFree( currReq, masterPr ); 231 case transfer_free_ptr: handleTransferFree( currReq, masterPr );
223 break; 232 break;
224 } 233 default:
225 } 234 break;
226 235 }
227 236 }
228 237
229 /*Work Stealing Alg -- racy one 238 /*Work Stealing Alg -- racy one
230 *This algorithm has a race condition -- the coreloops are accessing their 239 *This algorithm has a race condition -- the coreloops are accessing their
231 * own queues at the same time that this work-stealer on a different core 240 * own queues at the same time that this work-stealer on a different core
232 * is trying to. 241 * is trying to.