# HG changeset patch # User Me # Date 1277235452 25200 # Node ID 030fceb7e9b994f550800f5e485c10768102d435 # Parent c3e6c3fda84ea64c1b4c8eaf4f9525f0cd30f9b1 Kinda have test working -- assembly looks right for saving core loop frame and stack and restoring them But have a bug that looks timing-related, so thinking maybe some threads are going to completion? The whole test isn't quite right yet -- it throws exception because the suspended virtual processors never have a continuation put back into the workQ (is this right? Is that why it throws exception?) Want to move to full code to finish debugging diff -r c3e6c3fda84e -r 030fceb7e9b9 CoreLoop.c --- a/CoreLoop.c Tue Jun 22 11:53:32 2010 -0700 +++ b/CoreLoop.c Tue Jun 22 12:37:32 2010 -0700 @@ -69,11 +69,14 @@ currPr->coreAnimatedBy = coreLoopThdParams->coreNum; //switch to virt procr's stack and frame ptr then jump to virt procr - void *stackPtr, *framePtr, *jmpPt, *jmpPt_saveForLater; + void *stackPtr, *framePtr, *jmpPt, *coreLoopFramePtrAddr, \ + *coreLoopStackPtrAddr; stackPtr = currPr->stackPtr; framePtr = currPr->framePtr; jmpPt = currPr->nextInstrPt; + coreLoopFramePtrAddr = &(currPr->coreLoopFramePtr); + coreLoopStackPtrAddr = &(currPr->coreLoopStackPtr); //Save the core loop's stack and frame pointers into virt procr struct // then switch to stack ptr and frame ptr of virt procr & jmp to it @@ -82,14 +85,18 @@ // frame pointer, then tried to jump to an addr stored on stack, which // it accessed as an offset from frame-ptr! (wrong frame-ptr now) //Explicitly loading into eax before changing frame-ptr fixed it - asm volatile("movl %%ebp, %0; \ - movl %%esp, %1; \ - movl %2, %%eax; \ - movl %3, %%esp; \ - movl %4, %%ebp; \ - jmp %%eax" \ - /* outputs */ : "=g"(currPr->coreLoopFramePtr), \ - "=g"(currPr->coreLoopStackPtr) \ + //Also, it turns "(currPr->coreLoopFramePtr)" into a temporary on the + // stack, so "movl %%ebp, %0" saves to the temp, NOT the data-struc! + asm volatile("movl %0, %%eax; \ + movl %%esp, (%%eax); \ + movl %1, %%eax; \ + movl %%ebp, (%%eax); \ + movl %2, %%eax; \ + movl %3, %%esp; \ + movl %4, %%ebp; \ + jmp %%eax" \ + /* outputs */ : "=g"(coreLoopStackPtrAddr), \ + "=g"(coreLoopFramePtrAddr) \ /* inputs */ : "g" (jmpPt), "g" (stackPtr), "g" (framePtr) \ /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ );