Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
view ProcrContext.c @ 184:50b29548d4f0
handler interface for counters... not working
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 13 Jan 2012 15:03:32 +0100 |
| parents | 981acd1db6af |
| children | 20358f56e498 |
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->numTimesScheduled = 0;
27 newPr->initialData = initialData;
28 newPr->requests = NULL;
29 newPr->schedSlot = NULL;
31 /*
32 * Hardware dependent part
33 */
34 //instead of calling the function directly, call a wrapper function to fetch
35 //arguments from stack
36 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
38 //fnPtr takes two params -- void *initData & void *animProcr
39 //alloc stack locations, make stackPtr be the highest addr minus room
40 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
41 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
42 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
44 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
45 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
46 *((void**)stackPtr + 1 ) = initialData; //next param to left
47 *((void**)stackPtr) = (void*)fnPtr;
49 /*
50 * end of Hardware dependent part
51 */
53 newPr->stackPtr = stackPtr; //core loop will switch to this, then
54 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
56 //============================= MEASUREMENT STUFF ========================
57 #ifdef STATS__TURN_ON_PROBES
58 //struct timeval timeStamp;
59 //gettimeofday( &(timeStamp), NULL);
60 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
61 // _VMSMasterEnv->createPtInSecs;
62 #endif
63 #ifdef MEAS__PERF_COUNTERS
64 /*
65 newPr->counter_history = VMS__malloc(10*sizeof(void*));
66 newPr->counter_history_array_info = makePrivDynArrayInfoFrom((void*)&(newPr->counter_history),10);
67 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
68 newRecord->task_position = 0;
69 newRecord->vp_id = newPr->procrID;
70 newRecord->addr_of_libcall_for_req = fnPtr;
71 newRecord->sc_done_cycles = 0;
72 newRecord->sc_done_instrs = 0;
73 newRecord->req_cycles = 0;
74 newRecord->req_instrs = 0;
75 addToDynArray( (void*) newRecord, newPr->counter_history_array_info);
76 */
77 #endif
78 //========================================================================
80 return newPr;
81 }
