# HG changeset patch # User Me # Date 1275395500 25200 # Node ID 21842fec64dbbdfc90c9bce3029fca6cc8d1c568 # Parent 6c518bda83fe9c2e1b08cf6170418b3125ef7012 Added win thds and End Thd point diff -r 6c518bda83fe -r 21842fec64db CoreLoop.c --- a/CoreLoop.c Mon May 31 19:15:14 2010 -0700 +++ b/CoreLoop.c Tue Jun 01 05:31:40 2010 -0700 @@ -8,6 +8,7 @@ #include "VMS.h" #include "Queue_impl/BlockingQueue.h" +#include #include #include @@ -19,8 +20,8 @@ * write the slave's "Done" flag and repeat. */ //pthread_create requires ptr to func that takes void * and returns void * -void * -coreLoop( void *paramsIn ) +DWORD WINAPI +coreLoop( LPVOID paramsIn ) { ThdParams *thdParams; VirtProcr *currPr; @@ -28,7 +29,14 @@ // Get the communication queues out of the param passed in thdParams = (ThdParams *)paramsIn; + //Winblows requires pinning thd to core inside thread-function + //Designate a core by a 1 in bit-position corresponding to the core + SetThreadAffinityMask(GetCurrentThread(), 1 << thdParams->coreNum ); + //for non-gcc, can make macro that does asm that calls dummy that + // pulls addr off the stack and stores it in pointed-to location. + thdParams->endThdPt = &&EndCoreLoop; + //Core loop has no values live upon CoreLoopStartPt except workQ // every value in the code is defined by a statement in core loop, // after the start point, before being used -- with the one exception @@ -59,8 +67,11 @@ /* inputs */ : "g" (stackPtr), "g" (framePtr), "g" (jmpPt) /* clobber */ : "memory" /*just in case, Q: tell about esp, ebp?*/ ); + //======================================================================== + + //Note: will only exit when all work done -- so core loop's + // stack, which is the thread's stack, can be safely ignored + //jmp to here when want to shut down the VMS system + EndCoreLoop: + ExitThread( 0 ); } - //Note: will only exit this when application dies -- so core loop's stack - // can be safely ignored -- it's a user-process virtual chunk allocated - // by PThread lib call that created the thread.. so no cleanup is needed.. - // it's never used anywhere, except upon startup of the thread