# HG changeset patch # User Me # Date 1277000798 25200 # Node ID d801fe740275a9bd7a2774751f112d126e049589 # Parent e2de204909bfbcbdd78f1fa8669dfa31344a4820 Middle of testing core loop diff -r e2de204909bf -r d801fe740275 VMS.c --- a/VMS.c Sat Jun 19 19:26:12 2010 -0700 +++ b/VMS.c Sat Jun 19 19:26:38 2010 -0700 @@ -47,10 +47,10 @@ void VMS__init() { MasterEnv *masterEnv; - QueueStruc *workQ; + CASQueueStruc *workQ; //Make the central work-queue - _VMSWorkQ = makeQ(); + _VMSWorkQ = makeCASQ(); workQ = _VMSWorkQ; _VMSMasterEnv = malloc( sizeof(MasterEnv) ); @@ -68,7 +68,10 @@ //First core loop to start up gets this, which will schedule seed Pr //TODO: debug: check address of masterVirtPr - writeQ( masterEnv->masterVirtPr, workQ ); +//TODO: commented out for debugging -- put it back in!! +// writeCASQ( masterEnv->masterVirtPr, workQ ); + + numProcrsCreated = 1; } @@ -98,25 +101,25 @@ *This creates the core loops, pins them to physical cores, gives them the * pointer to the workQ, and starts them running. */ - void +void VMS__start() - { int retCode, coreIdx; + { int coreIdx; //Create the win threads that animate the core loops for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ) { - thdParams[coreIdx] = (ThdParams *)malloc( sizeof(ThdParams) ); - thdParams[coreIdx]->coreNum = coreIdx; + coreLoopThdParams[coreIdx] = (ThdParams *)malloc( sizeof(ThdParams) ); + coreLoopThdParams[coreIdx]->coreNum = coreIdx; - coreLoopThds[coreIdx] = - CreateThread ( NULL, // Security attributes - 0, // Stack size - coreLoop, - thdParams[coreIdx], - CREATE_SUSPENDED, - &(thdIds[coreIdx]) - ); - ResumeThread( coreLoopThds[coreIdx] ); //starts thread + coreLoopThdHandles[coreIdx] = + CreateThread ( NULL, // Security attributes + 0, // Stack size + coreLoop, + coreLoopThdParams[coreIdx], + CREATE_SUSPENDED, + &(coreLoopThdIds[coreIdx]) + ); + ResumeThread( coreLoopThdHandles[coreIdx] ); //starts thread } } @@ -138,6 +141,7 @@ char *stackLocs, *stackPtr; newPr = malloc( sizeof(VirtProcr) ); + newPr->procrID = numProcrsCreated++; newPr->nextInstrPt = fnPtr; newPr->initialData = initialData; @@ -146,8 +150,8 @@ stackLocs = malloc( 0x100000 ); //1 meg stack -- default Win thread's size stackPtr = ( (char *)stackLocs + 0x100000 - 0x8 ); //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp - *(stackPtr + 4) = newPr; //rightmost param - *stackPtr = initialData; //next param to left + *( (int *)stackPtr + 1) = (int) newPr; //rightmost param -- 32bit pointer + *( (int *)stackPtr ) = (int) initialData; //next param to left newPr->stackPtr = stackPtr; //core loop will switch to this, then newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr @@ -198,7 +202,9 @@ /* outputs */ : "=g" (stackPtr), "=g" (framePtr) /* inputs */ : "g" (jmpPt) /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi","%esi" - ); + ); //list everything as clobbered to force GCC to save all + // live vars that are in regs on stack before this + // assembly, so that stack pointer is correct, before jmp ResumePt: return; @@ -229,4 +235,17 @@ { } - } \ No newline at end of file + } + + + +inline TSCount getTSCount() + { unsigned int low, high; + TSCount out; + + saveTimeStampCountInto( low, high ); + out = high; + out = (out << 32) + low; + return out; + } +