annotate ProcrContext.c @ 195:d83f59e6e2db

eliminate spurious head
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Thu, 09 Feb 2012 17:54:54 +0100
parents 50b29548d4f0
children
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;
nengel@193 30 newPr->isMasterVP = FALSE;
nengel@193 31 newPr->isShutdownVP = FALSE;
msach@77 32 /*
msach@77 33 * Hardware dependent part
msach@77 34 */
msach@77 35 //instead of calling the function directly, call a wrapper function to fetch
msach@77 36 //arguments from stack
msach@77 37 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
msach@77 38
msach@77 39 //fnPtr takes two params -- void *initData & void *animProcr
msach@77 40 //alloc stack locations, make stackPtr be the highest addr minus room
msach@77 41 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
msach@77 42 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
msach@77 43 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
msach@77 44
msach@77 45 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
msach@77 46 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
msach@77 47 *((void**)stackPtr + 1 ) = initialData; //next param to left
msach@77 48 *((void**)stackPtr) = (void*)fnPtr;
msach@77 49
msach@77 50 /*
msach@77 51 * end of Hardware dependent part
msach@77 52 */
msach@77 53
msach@77 54 newPr->stackPtr = stackPtr; //core loop will switch to this, then
msach@77 55 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
msach@77 56
msach@77 57 //============================= MEASUREMENT STUFF ========================
msach@77 58 #ifdef STATS__TURN_ON_PROBES
msach@78 59 //struct timeval timeStamp;
msach@78 60 //gettimeofday( &(timeStamp), NULL);
msach@78 61 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
msach@78 62 // _VMSMasterEnv->createPtInSecs;
msach@77 63 #endif
Nina@109 64 #ifdef MEAS__PERF_COUNTERS
nengel@184 65 /*
Nina@109 66 newPr->counter_history = VMS__malloc(10*sizeof(void*));
Nina@129 67 newPr->counter_history_array_info = makePrivDynArrayInfoFrom((void*)&(newPr->counter_history),10);
Nina@109 68 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
Nina@111 69 newRecord->task_position = 0;
Nina@112 70 newRecord->vp_id = newPr->procrID;
Nina@112 71 newRecord->addr_of_libcall_for_req = fnPtr;
Nina@165 72 newRecord->sc_done_cycles = 0;
Nina@165 73 newRecord->sc_done_instrs = 0;
Nina@165 74 newRecord->req_cycles = 0;
Nina@165 75 newRecord->req_instrs = 0;
Nina@109 76 addToDynArray( (void*) newRecord, newPr->counter_history_array_info);
nengel@184 77 */
Nina@109 78 #endif
msach@77 79 //========================================================================
msach@77 80
msach@77 81 return newPr;
msach@77 82 }