Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 6:21842fec64db
Added win thds and End Thd point
| author | Me |
|---|---|
| date | Tue, 01 Jun 2010 05:31:40 -0700 |
| parents | 6c518bda83fe |
| children | f96e4b3b35c7 |
| files | CoreLoop.c |
| diffstat | 1 files changed, 17 insertions(+), 6 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Mon May 31 19:15:14 2010 -0700 1.2 +++ b/CoreLoop.c Tue Jun 01 05:31:40 2010 -0700 1.3 @@ -8,6 +8,7 @@ 1.4 #include "VMS.h" 1.5 #include "Queue_impl/BlockingQueue.h" 1.6 1.7 +#include <windows.h> 1.8 #include <stdio.h> 1.9 #include <time.h> 1.10 1.11 @@ -19,8 +20,8 @@ 1.12 * write the slave's "Done" flag and repeat. 1.13 */ 1.14 //pthread_create requires ptr to func that takes void * and returns void * 1.15 -void * 1.16 -coreLoop( void *paramsIn ) 1.17 +DWORD WINAPI 1.18 +coreLoop( LPVOID paramsIn ) 1.19 { 1.20 ThdParams *thdParams; 1.21 VirtProcr *currPr; 1.22 @@ -28,7 +29,14 @@ 1.23 1.24 // Get the communication queues out of the param passed in 1.25 thdParams = (ThdParams *)paramsIn; 1.26 + //Winblows requires pinning thd to core inside thread-function 1.27 + //Designate a core by a 1 in bit-position corresponding to the core 1.28 + SetThreadAffinityMask(GetCurrentThread(), 1 << thdParams->coreNum ); 1.29 1.30 + //for non-gcc, can make macro that does asm that calls dummy that 1.31 + // pulls addr off the stack and stores it in pointed-to location. 1.32 + thdParams->endThdPt = &&EndCoreLoop; 1.33 + 1.34 //Core loop has no values live upon CoreLoopStartPt except workQ 1.35 // every value in the code is defined by a statement in core loop, 1.36 // after the start point, before being used -- with the one exception 1.37 @@ -59,8 +67,11 @@ 1.38 /* inputs */ : "g" (stackPtr), "g" (framePtr), "g" (jmpPt) 1.39 /* clobber */ : "memory" /*just in case, Q: tell about esp, ebp?*/ 1.40 ); 1.41 + //======================================================================== 1.42 + 1.43 + //Note: will only exit when all work done -- so core loop's 1.44 + // stack, which is the thread's stack, can be safely ignored 1.45 + //jmp to here when want to shut down the VMS system 1.46 + EndCoreLoop: 1.47 + ExitThread( 0 ); 1.48 } 1.49 - //Note: will only exit this when application dies -- so core loop's stack 1.50 - // can be safely ignored -- it's a user-process virtual chunk allocated 1.51 - // by PThread lib call that created the thread.. so no cleanup is needed.. 1.52 - // it's never used anywhere, except upon startup of the thread
