annotate ProcrContext.c @ 111:b1817e2451b1

add task # to counter stats
author Nina Engelhardt
date Fri, 05 Aug 2011 18:03:07 +0200
parents 659299627e70
children fac1d896f6e9
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++;
msach@77 26 newPr->initialData = initialData;
msach@77 27 newPr->requests = NULL;
msach@77 28 newPr->schedSlot = NULL;
msach@77 29
msach@77 30 /*
msach@77 31 * Hardware dependent part
msach@77 32 */
msach@77 33 //instead of calling the function directly, call a wrapper function to fetch
msach@77 34 //arguments from stack
msach@77 35 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
msach@77 36
msach@77 37 //fnPtr takes two params -- void *initData & void *animProcr
msach@77 38 //alloc stack locations, make stackPtr be the highest addr minus room
msach@77 39 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
msach@77 40 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
msach@77 41 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
msach@77 42
msach@77 43 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
msach@77 44 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
msach@77 45 *((void**)stackPtr + 1 ) = initialData; //next param to left
msach@77 46 *((void**)stackPtr) = (void*)fnPtr;
msach@77 47
msach@77 48 /*
msach@77 49 * end of Hardware dependent part
msach@77 50 */
msach@77 51
msach@77 52 newPr->stackPtr = stackPtr; //core loop will switch to this, then
msach@77 53 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
msach@77 54
msach@77 55 //============================= MEASUREMENT STUFF ========================
msach@77 56 #ifdef STATS__TURN_ON_PROBES
msach@78 57 //struct timeval timeStamp;
msach@78 58 //gettimeofday( &(timeStamp), NULL);
msach@78 59 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
msach@78 60 // _VMSMasterEnv->createPtInSecs;
msach@77 61 #endif
Nina@109 62 #ifdef MEAS__PERF_COUNTERS
Nina@109 63 newPr->counter_history = VMS__malloc(10*sizeof(void*));
Nina@109 64 newPr->counter_history_array_info = makePrivDynArrayInfoFrom(&(newPr->counter_history),10);
Nina@109 65 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
Nina@111 66 newRecord->task_position = 0;
Nina@109 67 addToDynArray( (void*) newRecord, newPr->counter_history_array_info);
Nina@109 68 #endif
msach@77 69 //========================================================================
msach@77 70
msach@77 71 return newPr;
msach@77 72 }