comparison VMS.c @ 76:9ddbb071142d

make hardware independent and port to 64bit
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 16 Jun 2011 14:41:15 +0200
parents f6990e1ba998
children fe5ec83f1baf
comparison
equal deleted inserted replaced
39:bc1c7b400e78 40:d7ea8d2cfe8f
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <malloc.h> 10 #include <malloc.h>
11 #include <inttypes.h>
11 #include <sys/time.h> 12 #include <sys/time.h>
12 13
13 #include "VMS.h" 14 #include "VMS.h"
14 #include "SwitchAnimators.h" 15 #include "SwitchAnimators.h"
15 #include "Queue_impl/BlockingQueue.h" 16 #include "Queue_impl/BlockingQueue.h"
136 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 137 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
137 { 138 {
138 readyToAnimateQs[ coreIdx ] = makeVMSQ(); 139 readyToAnimateQs[ coreIdx ] = makeVMSQ();
139 140
140 //Q: should give masterVP core-specific info as its init data? 141 //Q: should give masterVP core-specific info as its init data?
141 masterVPs[ coreIdx ] = VMS__create_procr( &masterLoop, masterEnv ); 142 masterVPs[ coreIdx ] = VMS__create_procr( (VirtProcrFnPtr)&masterLoop, (void*)masterEnv );
142 masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; 143 masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
143 allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core 144 allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core
144 _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0; 145 _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0;
145 _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL; 146 _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL;
146 } 147 }
173 "master lock low time hist"); 174 "master lock low time hist");
174 _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100, 175 _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,
175 "master lock high time hist"); 176 "master lock high time hist");
176 #endif 177 #endif
177 178
178 MakeTheMeasHists 179 MakeTheMeasHists();
179 //======================================================================== 180 //========================================================================
180 181
181 } 182 }
182 183
183 SchedSlot ** 184 SchedSlot **
291 * animator state to return to -- 292 * animator state to return to --
292 * 293 *
293 */ 294 */
294 inline VirtProcr * 295 inline VirtProcr *
295 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr, 296 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr,
296 void *initialData, char *stackLocs ) 297 void *initialData, void *stackLocs )
297 { 298 {
298 char *stackPtr; 299 void *stackPtr;
299 300
300 newPr->startOfStack = stackLocs; 301 newPr->startOfStack = stackLocs;
301 newPr->procrID = _VMSMasterEnv->numProcrsCreated++; 302 newPr->procrID = _VMSMasterEnv->numProcrsCreated++;
302 newPr->nextInstrPt = fnPtr;
303 newPr->initialData = initialData; 303 newPr->initialData = initialData;
304 newPr->requests = NULL; 304 newPr->requests = NULL;
305 newPr->schedSlot = NULL; 305 newPr->schedSlot = NULL;
306 306
307 //fnPtr takes two params -- void *initData & void *animProcr 307 /*
308 //alloc stack locations, make stackPtr be the highest addr minus room 308 * Hardware dependent part
309 // for 2 params + return addr. Return addr (NULL) is in loc pointed to 309 */
310 // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above 310 //instead of calling the function directly, call a wrapper function to fetch
311 stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 ); 311 //arguments from stack
312 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
313
314 //fnPtr takes two params -- void *initData & void *animProcr
315 //alloc stack locations, make stackPtr be the highest addr minus room
316 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
317 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
318 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
312 319
313 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp 320 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
314 *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer 321 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
315 *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left 322 *((void**)stackPtr + 1 ) = initialData; //next param to left
323 *((void**)stackPtr) = (void*)fnPtr;
324
325 /*
326 * end of Hardware dependent part
327 */
328
316 newPr->stackPtr = stackPtr; //core loop will switch to this, then 329 newPr->stackPtr = stackPtr; //core loop will switch to this, then
317 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr 330 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
318 331
319 //============================= MEASUREMENT STUFF ======================== 332 //============================= MEASUREMENT STUFF ========================
320 #ifdef STATS__TURN_ON_PROBES 333 #ifdef STATS__TURN_ON_PROBES
329 } 342 }
330 343
331 inline VirtProcr * 344 inline VirtProcr *
332 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ) 345 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData )
333 { VirtProcr *newPr; 346 { VirtProcr *newPr;
334 char *stackLocs; 347 void *stackLocs;
335 348
336 newPr = VMS__malloc( sizeof(VirtProcr) ); 349 newPr = VMS__malloc( sizeof(VirtProcr) );
337 stackLocs = VMS__malloc( VIRT_PROCR_STACK_SIZE ); 350 stackLocs = VMS__malloc( VIRT_PROCR_STACK_SIZE );
338 if( stackLocs == 0 ) 351 if( stackLocs == 0 )
339 { perror("VMS__malloc stack"); exit(1); } 352 { perror("VMS__malloc stack"); exit(1); }
583 void inline 596 void inline
584 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv, 597 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
585 ResumePrFnPtr resumePrFnPtr ) 598 ResumePrFnPtr resumePrFnPtr )
586 { VMSSemReq *semReq; 599 { VMSSemReq *semReq;
587 IntervalProbe *newProbe; 600 IntervalProbe *newProbe;
588 int32 nameLen;
589 601
590 semReq = req->semReqData; 602 semReq = req->semReqData;
591 603
592 newProbe = VMS__malloc( sizeof(IntervalProbe) ); 604 newProbe = VMS__malloc( sizeof(IntervalProbe) );
593 newProbe->nameStr = VMS__strDup( semReq->nameStr ); 605 newProbe->nameStr = VMS__strDup( semReq->nameStr );