annotate ProcrContext.c @ 187:fe5ad5726e36

counters working ...sort of
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Fri, 03 Feb 2012 17:32:48 +0100
parents 981acd1db6af
children 20358f56e498
rev   line source
msach@77 1 /*
msach@77 2 * This File contains all hardware dependent C code.
msach@77 3 */
msach@77 4
msach@77 5
msach@77 6 #include "VMS.h"
msach@77 7
msach@77 8 /*Create stack, then create __cdecl structure on it and put initialData and
msach@77 9 * pointer to the new structure instance into the parameter positions on
msach@77 10 * the stack
msach@77 11 *Then put function pointer into nextInstrPt -- the stack is setup in std
msach@77 12 * call structure, so jumping to function ptr is same as a GCC generated
msach@77 13 * function call
msach@77 14 *No need to save registers on old stack frame, because there's no old
msach@77 15 * animator state to return to --
msach@77 16 *
msach@77 17 */
msach@77 18 inline VirtProcr *
msach@77 19 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr,
msach@77 20 void *initialData, void *stackLocs )
msach@77 21 {
msach@77 22 void *stackPtr;
msach@77 23
msach@77 24 newPr->startOfStack = stackLocs;
msach@77 25 newPr->procrID = _VMSMasterEnv->numProcrsCreated++;
Nina@167 26 newPr->numTimesScheduled = 0;
msach@77 27 newPr->initialData = initialData;
msach@77 28 newPr->requests = NULL;
msach@77 29 newPr->schedSlot = NULL;
msach@77 30
msach@77 31 /*
msach@77 32 * Hardware dependent part
msach@77 33 */
msach@77 34 //instead of calling the function directly, call a wrapper function to fetch
msach@77 35 //arguments from stack
msach@77 36 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
msach@77 37
msach@77 38 //fnPtr takes two params -- void *initData & void *animProcr
msach@77 39 //alloc stack locations, make stackPtr be the highest addr minus room
msach@77 40 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
msach@77 41 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
msach@77 42 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
msach@77 43
msach@77 44 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
msach@77 45 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
msach@77 46 *((void**)stackPtr + 1 ) = initialData; //next param to left
msach@77 47 *((void**)stackPtr) = (void*)fnPtr;
msach@77 48
msach@77 49 /*
msach@77 50 * end of Hardware dependent part
msach@77 51 */
msach@77 52
msach@77 53 newPr->stackPtr = stackPtr; //core loop will switch to this, then
msach@77 54 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
msach@77 55
msach@77 56 //============================= MEASUREMENT STUFF ========================
msach@77 57 #ifdef STATS__TURN_ON_PROBES
msach@78 58 //struct timeval timeStamp;
msach@78 59 //gettimeofday( &(timeStamp), NULL);
msach@78 60 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
msach@78 61 // _VMSMasterEnv->createPtInSecs;
msach@77 62 #endif
Nina@109 63 #ifdef MEAS__PERF_COUNTERS
nengel@184 64 /*
Nina@109 65 newPr->counter_history = VMS__malloc(10*sizeof(void*));
Nina@129 66 newPr->counter_history_array_info = makePrivDynArrayInfoFrom((void*)&(newPr->counter_history),10);
Nina@109 67 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
Nina@111 68 newRecord->task_position = 0;
Nina@112 69 newRecord->vp_id = newPr->procrID;
Nina@112 70 newRecord->addr_of_libcall_for_req = fnPtr;
Nina@165 71 newRecord->sc_done_cycles = 0;
Nina@165 72 newRecord->sc_done_instrs = 0;
Nina@165 73 newRecord->req_cycles = 0;
Nina@165 74 newRecord->req_instrs = 0;
Nina@109 75 addToDynArray( (void*) newRecord, newPr->counter_history_array_info);
nengel@184 76 */
Nina@109 77 #endif
msach@77 78 //========================================================================
msach@77 79
msach@77 80 return newPr;
msach@77 81 }