# HG changeset patch # User Merten Sach # Date 1307015751 -7200 # Node ID f6990e1ba998c12eca4f19791f3669d89eeb8850 # Parent 77df6692bb2954315916af0f2b26ef7f34ed915d new sequential version diff -r 77df6692bb29 -r f6990e1ba998 CoreLoop.c --- a/CoreLoop.c Thu Jun 02 12:45:02 2011 +0200 +++ b/CoreLoop.c Thu Jun 02 13:55:51 2011 +0200 @@ -76,7 +76,8 @@ //Save the return address in the SwitchVP function - saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt)); + saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt)); + while(1){ @@ -152,6 +153,7 @@ }//CoreLoop } + void * terminateCoreLoop(VirtProcr *currPr){ //first free shutdown VP that jumped here -- it first restores the @@ -161,6 +163,7 @@ } + #ifdef SEQUENTIAL //=========================================================================== @@ -180,24 +183,11 @@ // thisCoresIdx = coreLoopThdParams->coreNum; thisCoresIdx = 0; + //Save the return address in the SwitchVP function + saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt)); - //Save addr of "end core loop" label - jump to it to shut down coreloop - //To get label addr in non-gcc compiler, can trick it by making a call - // to a fn that does asm that pulls the "return" - // addr off the stack and stores it in a pointed-to location. - _VMSMasterEnv->coreLoopStartPt = &&SeqCoreLoopStartPt; - _VMSMasterEnv->coreLoopEndPt = &&SeqCoreLoopEndPt; - - //Core loop has no values live upon CoreLoopStartPt except readyToAnimateQ - // every value in the code is defined by a statement in core loop, - // after the start point -- with the one exception of _VMSWorkQ - - - // Get to work! -- virt procr jumps back here when done or suspends - //Note, have to restore the frame-pointer before jump to here, to get - // this code to work right (readyToAnimateQ and so forth are frame-ptr relative) -SeqCoreLoopStartPt: - + + while(1){ //Get virtual processor from queue //_VMSWorkQ must be a global, static volatile var, so not kept in reg, // which forces reloading the pointer after each jmp to this point @@ -214,18 +204,8 @@ _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; - SwitchToVP( currPr ) - - //======================================================================== - //jmp to here when want to shut down the VMS system. A shutdown VP is - // made, one for each core loop -- its function sets the stack back - // to the core loop's stack then jumps to here. This causes the thread - // to exit, and so the entry point function, which has been waiting for - // all the threads to die will proceed, gather the result, and - // return to the calling application. -SeqCoreLoopEndPt: - VMS__dissipate_procr( currPr ); //free shutdown pr, that jmpd here - return; + switchToVP( currPr ); + flushRegisters(); + } } - #endif diff -r 77df6692bb29 -r f6990e1ba998 VMS.c --- a/VMS.c Thu Jun 02 12:45:02 2011 +0200 +++ b/VMS.c Thu Jun 02 13:55:51 2011 +0200 @@ -276,6 +276,7 @@ //Instead of un-suspending threads, just call the one and only // core loop (sequential version), in the main thread. coreLoop_Seq( NULL ); + flushRegisters(); } #endif @@ -704,7 +705,11 @@ void endOSThreadFn( void *initData, VirtProcr *animatingPr ) { +#ifdef SEQUENTIAL + asmTerminateCoreLoopSeq(animatingPr); +#else asmTerminateCoreLoop(animatingPr); +#endif } diff -r 77df6692bb29 -r f6990e1ba998 contextSwitch.s --- a/contextSwitch.s Thu Jun 02 12:45:02 2011 +0200 +++ b/contextSwitch.s Thu Jun 02 13:55:51 2011 +0200 @@ -121,5 +121,22 @@ movl 0x20(%ecx), %esp #restore stack pointer movl 0x1c(%ecx), %ebp #restore frame pointer movl $terminateCoreLoop, %eax - jmp *%eax #jmp to CoreLoop + jmp *%eax #jmp to CoreLoop + + +/* + * This one for the sequential version is special. It discards the current stack + * and returns directly from the coreLoop after VMS__dissipate_procr was called + */ +.globl asmTerminateCoreLoopSeq +asmTerminateCoreLoopSeq: + movl 0x4(%esp) , %ecx #get VirtProcr + movl 0x20(%ecx), %esp #restore stack pointer + movl 0x1c(%ecx), %ebp #restore frame pointer + sub $0x4 , %esp + movl %ecx , (%esp) #put argument on stack + call VMS__dissipate_procr + movl %ebp , %esp #goto the coreLoops stack + pop %ebp #restore the old framepointer + ret #return from core loop