Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff VMS.c @ 14:65c8fb2821ee
Forgot to commit after had working test -- changed stack & frame ptrs in thd params
to be instead in virt procr struc -- stopped working! Saving now, then going back to
way had it..
| author | Me |
|---|---|
| date | Tue, 22 Jun 2010 11:52:41 -0700 |
| parents | d801fe740275 |
| children | 734c665500e4 |
line diff
1.1 --- a/VMS.c Sat Jun 19 19:26:49 2010 -0700 1.2 +++ b/VMS.c Tue Jun 22 11:52:41 2010 -0700 1.3 @@ -105,6 +105,7 @@ 1.4 VMS__start() 1.5 { int coreIdx; 1.6 1.7 + //TODO: Save "orig" stack pointer and frame ptr -- restore in VMS__end() 1.8 //Create the win threads that animate the core loops 1.9 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ) 1.10 { 1.11 @@ -145,13 +146,15 @@ 1.12 newPr->nextInstrPt = fnPtr; 1.13 newPr->initialData = initialData; 1.14 1.15 + //fnPtr takes two params -- void *initData & void *animProcr 1.16 //alloc stack locations, make stackPtr be the highest addr minus room 1.17 - // for 2 params. Put initData at stackPtr, animatingPr just above 1.18 + // for 2 params + return addr. Return addr (NULL) is in loc pointed to 1.19 + // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above 1.20 stackLocs = malloc( 0x100000 ); //1 meg stack -- default Win thread's size 1.21 - stackPtr = ( (char *)stackLocs + 0x100000 - 0x8 ); 1.22 + stackPtr = ( (char *)stackLocs + 0x100000 - 0x10 ); 1.23 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp 1.24 - *( (int *)stackPtr + 1) = (int) newPr; //rightmost param -- 32bit pointer 1.25 - *( (int *)stackPtr ) = (int) initialData; //next param to left 1.26 + *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer 1.27 + *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left 1.28 newPr->stackPtr = stackPtr; //core loop will switch to this, then 1.29 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr 1.30 1.31 @@ -183,25 +186,38 @@ 1.32 */ 1.33 void 1.34 VMS__suspend_processor( VirtProcr *callingPr ) 1.35 - { void *jmpPt, *stackPtr, *framePtr; 1.36 + { void *jmpPt, *stackPtrAddr, *framePtrAddr, *coreLoopStackPtr; 1.37 + void *coreLoopFramePtr; 1.38 + int coreIdx; 1.39 1.40 + //The request to master will cause this suspended virt procr to get 1.41 + // scheduled again at some future point -- to resume, core loop jumps 1.42 + // to the resume point (below), which causes restore of saved regs and 1.43 + // "return" from this call. 1.44 callingPr->nextInstrPt = &&ResumePt; 1.45 1.46 //return ownership of the virt procr and sched slot to Master virt pr 1.47 callingPr->schedSlot->workIsDone = TRUE; 1.48 +// coreIdx = callingPr->coreAnimatedBy; 1.49 1.50 - jmpPt = callingPr->coreLoopStartPt; 1.51 - stackPtr = &(callingPr->stackPtr); 1.52 - framePtr = &(callingPr->framePtr); 1.53 +// stackPtrAddr = &(callingPr->stackPtr); 1.54 +// framePtrAddr = &(callingPr->framePtr); 1.55 + 1.56 + jmpPt = callingPr->coreLoopStartPt; 1.57 + coreLoopFramePtr = callingPr->coreLoopFramePtr;//need this only 1.58 + coreLoopStackPtr = callingPr->coreLoopStackPtr; 1.59 +// coreLoopStackPtr = coreLoopThdParams[ coreIdx ]->stackPtr;//prob dont need 1.60 1.61 - //put all regs in the clobber list to make sure GCC has saved all 1.62 - // so safe to jump to core loop, where they *will* get clobbered 1.63 + //Save the virt procr's stack and frame ptrs, restore coreloop's frame 1.64 + // ptr, then jump back to "start" of core loop 1.65 asm volatile("movl %%esp, %0; \ 1.66 movl %%ebp, %1; \ 1.67 - jmp %2 " 1.68 - /* outputs */ : "=g" (stackPtr), "=g" (framePtr) 1.69 - /* inputs */ : "g" (jmpPt) 1.70 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi","%esi" 1.71 + movl %3, %%eax; \ 1.72 + movl %2, %%ebp; \ 1.73 + jmp %%eax " \ 1.74 + /* outputs */ : "=g" (callingPr->stackPtr), "=g" (callingPr->framePtr) \ 1.75 + /* inputs */ : "g"(coreLoopFramePtr), "g" (jmpPt) \ 1.76 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi","%esi" \ 1.77 ); //list everything as clobbered to force GCC to save all 1.78 // live vars that are in regs on stack before this 1.79 // assembly, so that stack pointer is correct, before jmp 1.80 @@ -229,11 +245,17 @@ 1.81 void 1.82 VMS__shutdown() 1.83 { int coreIdx; 1.84 + VirtProcr *shutDownPr; 1.85 1.86 - //Create the win threads that animate the core loops 1.87 + //TODO: restore the "orig" stack pointer and frame ptr saved in VMS__start 1.88 + //create a "special" virtual processor, one for each core loop that has 1.89 + // the "loop end" point as its "next instr" point -- when the core loop 1.90 + // jumps to animate the virt procr, the jump lands it at its own 1.91 + // shut-down code. 1.92 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ) 1.93 { 1.94 - 1.95 + shutDownPr = VMS__create_procr( NULL, NULL ); 1.96 + shutDownPr->nextInstrPt = _VMSMasterEnv->coreLoopShutDownPt; 1.97 } 1.98 } 1.99
