view ProcrContext.c @ 108:3bc3b89630c7

perf counters
author engelhardt@cray1
date Tue, 26 Jul 2011 15:36:24 +0200
parents 521c75d64cef
children 659299627e70
line source
1 /*
2 * This File contains all hardware dependent C code.
3 */
6 #include "VMS.h"
8 /*Create stack, then create __cdecl structure on it and put initialData and
9 * pointer to the new structure instance into the parameter positions on
10 * the stack
11 *Then put function pointer into nextInstrPt -- the stack is setup in std
12 * call structure, so jumping to function ptr is same as a GCC generated
13 * function call
14 *No need to save registers on old stack frame, because there's no old
15 * animator state to return to --
16 *
17 */
18 inline VirtProcr *
19 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr,
20 void *initialData, void *stackLocs )
21 {
22 void *stackPtr;
24 newPr->startOfStack = stackLocs;
25 newPr->procrID = _VMSMasterEnv->numProcrsCreated++;
26 newPr->initialData = initialData;
27 newPr->requests = NULL;
28 newPr->schedSlot = NULL;
30 /*
31 * Hardware dependent part
32 */
33 //instead of calling the function directly, call a wrapper function to fetch
34 //arguments from stack
35 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
37 //fnPtr takes two params -- void *initData & void *animProcr
38 //alloc stack locations, make stackPtr be the highest addr minus room
39 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
40 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
41 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
43 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
44 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
45 *((void**)stackPtr + 1 ) = initialData; //next param to left
46 *((void**)stackPtr) = (void*)fnPtr;
48 /*
49 * end of Hardware dependent part
50 */
52 newPr->stackPtr = stackPtr; //core loop will switch to this, then
53 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
55 //============================= MEASUREMENT STUFF ========================
56 #ifdef STATS__TURN_ON_PROBES
57 //struct timeval timeStamp;
58 //gettimeofday( &(timeStamp), NULL);
59 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
60 // _VMSMasterEnv->createPtInSecs;
61 #endif
63 //========================================================================
65 return newPr;
66 }