Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 137:99343ffe1918 Inter-Master Requests
The shutdown now uses inter master requests
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 19 Sep 2011 14:15:37 +0200 |
| parents | f1374d5dbb98 |
| children | 99798e4438a6 000f8bcdc4c2 |
| files | CoreLoop.c MasterLoop.c ProcrContext.h VMS.c VMS.h contextSwitch.s inter_VMS_requests.h inter_VMS_requests_handler.c inter_VMS_requests_handler.h vmalloc.c |
| diffstat | 10 files changed, 47 insertions(+), 29 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Fri Sep 16 20:13:33 2011 +0200 1.2 +++ b/CoreLoop.c Mon Sep 19 14:15:37 2011 +0200 1.3 @@ -160,16 +160,11 @@ 1.4 1.5 void * 1.6 terminateCoreLoop(VirtProcr *currPr){ 1.7 - //first free the shutdown VP that jumped here -- it first restores the 1.8 - // coreloop's stack, so addr of currPr in stack frame is still correct 1.9 - VMS__dissipate_procr( currPr ); 1.10 - pthread_exit( NULL ); 1.11 + pthread_exit( NULL ); 1.12 } 1.13 1.14 1.15 1.16 -#ifdef SEQUENTIAL 1.17 - 1.18 //=========================================================================== 1.19 /*This sequential version is exact same as threaded, except doesn't do the 1.20 * pin-threads part, nor the wait until setup complete part. 1.21 @@ -188,7 +183,7 @@ 1.22 thisCoresIdx = 0; 1.23 1.24 //Save the return address in the SwitchVP function 1.25 - saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt)); 1.26 + saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); 1.27 1.28 1.29 while(1){ 1.30 @@ -212,4 +207,3 @@ 1.31 flushRegisters(); 1.32 } 1.33 } 1.34 -#endif
2.1 --- a/MasterLoop.c Fri Sep 16 20:13:33 2011 +0200 2.2 +++ b/MasterLoop.c Mon Sep 19 14:15:37 2011 +0200 2.3 @@ -238,12 +238,17 @@ 2.4 void inline 2.5 handleInterVMSCoreReq( InterVMSCoreReqst *currReq, VirtProcr *masterPr ) 2.6 { 2.7 - switch( currReq->reqType ) 2.8 + switch( currReq->secondReqType ) 2.9 { 2.10 case transfer_free_ptr: 2.11 handleTransferFree( currReq, masterPr ); 2.12 currReq->obsolete = 1; //now the sender can free the structure 2.13 break; 2.14 + case shutdownVP: 2.15 + currReq->obsolete = 1; 2.16 + handleShutdown(currReq, masterPr); 2.17 + //The Execution of the MasterLoop ends here 2.18 + break; 2.19 default: 2.20 break; 2.21 }
3.1 --- a/ProcrContext.h Fri Sep 16 20:13:33 2011 +0200 3.2 +++ b/ProcrContext.h Mon Sep 19 14:15:37 2011 +0200 3.3 @@ -65,7 +65,9 @@ 3.4 3.5 void startVirtProcrFn(); 3.6 3.7 -void *asmTerminateCoreLoop(VirtProcr *currPr); 3.8 +void asmTerminateCoreLoop(VirtProcr *currPr); 3.9 + 3.10 +void asmTerminateCoreLoopSeq(VirtProcr *currPr); 3.11 3.12 #define flushRegisters() \ 3.13 asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15");
4.1 --- a/VMS.c Fri Sep 16 20:13:33 2011 +0200 4.2 +++ b/VMS.c Mon Sep 19 14:15:37 2011 +0200 4.3 @@ -619,13 +619,9 @@ 4.4 // itself 4.5 //Note, should not stack-allocate initial data -- no guarantee, in 4.6 // general that creating processor will outlive ones it creates. 4.7 - 4.8 - 4.9 - /* 4.10 - * call the core specific version, because the creating master can already be dead 4.11 - */ 4.12 - //VMS__free_in_lib( animatingPr->startOfStack, animatingPr ); 4.13 - //VMS__free_in_lib( animatingPr, animatingPr); 4.14 + 4.15 + VMS__free( animatingPr->startOfStack); 4.16 + VMS__free( animatingPr); 4.17 } 4.18 4.19 4.20 @@ -664,14 +660,12 @@ 4.21 void 4.22 VMS__shutdown() 4.23 { int coreIdx; 4.24 - VirtProcr *shutDownPr; 4.25 - 4.26 - //create the shutdown processors, one for each core loop -- put them 4.27 - // directly into the Q -- each core will die when gets one 4.28 + //Send a shutdown Request to all MasterLoops. 4.29 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ) 4.30 { //Note, this is running in the master 4.31 - shutDownPr = VMS__create_procr( &endOSThreadFn, NULL ); 4.32 - writeVMSQ( shutDownPr, _VMSMasterEnv->readyToAnimateQs[coreIdx] ); 4.33 + InterVMSCoreReqst *shutdownReqst = VMS__malloc(sizeof(InterVMSCoreReqst)); 4.34 + shutdownReqst->secondReqType = shutdownVP; 4.35 + sendInterMasterReqst(coreIdx, (InterMasterReqst*)shutdownReqst); 4.36 } 4.37 4.38 } 4.39 @@ -690,6 +684,7 @@ 4.40 * to core loop function -- note that this slices out a level of virtual 4.41 * processors). 4.42 */ 4.43 +/* 4.44 void 4.45 endOSThreadFn( void *initData, VirtProcr *animatingPr ) 4.46 { 4.47 @@ -699,6 +694,7 @@ 4.48 asmTerminateCoreLoop(animatingPr); 4.49 #endif 4.50 } 4.51 + */ 4.52 4.53 4.54 /*This is called from the startup & shutdown
5.1 --- a/VMS.h Fri Sep 16 20:13:33 2011 +0200 5.2 +++ b/VMS.h Mon Sep 19 14:15:37 2011 +0200 5.3 @@ -49,9 +49,9 @@ 5.4 #define DEBUG2( bool, msg, p1, p2) \ 5.5 // if(bool) {printf(msg, p1, p2); fflush(stdin);} 5.6 5.7 -#define ERROR(msg) printf(msg); 5.8 -#define ERROR1(msg, param) printf(msg, param); 5.9 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 5.10 +#define ERROR(msg) printf(msg) 5.11 +#define ERROR1(msg, param) printf(msg, param); 5.12 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2) 5.13 5.14 //=========================== STATS ======================= 5.15
6.1 --- a/contextSwitch.s Fri Sep 16 20:13:33 2011 +0200 6.2 +++ b/contextSwitch.s Mon Sep 19 14:15:37 2011 +0200 6.3 @@ -94,6 +94,9 @@ 6.4 #VirtProcr in %rdi 6.5 movq 0x38(%rdi), %rsp #restore stack pointer 6.6 movq 0x30(%rdi), %rbp #restore frame pointer 6.7 + movq $_VMSMasterEnv, %rcx 6.8 + movq (%rcx) , %rcx 6.9 + movl $0x0 , 0x44(%rcx) #release lock 6.10 movq $terminateCoreLoop, %rax 6.11 jmp *%rax #jmp to CoreLoop 6.12 6.13 @@ -108,7 +111,6 @@ 6.14 movq 0x38(%rdi), %rsp #restore stack pointer 6.15 movq 0x30(%rdi), %rbp #restore frame pointer 6.16 #argument is in %rdi 6.17 - call VMS__dissipate_procr 6.18 movq %rbp , %rsp #goto the coreLoops stack 6.19 pop %rbp #restore the old framepointer 6.20 ret #return from core loop
7.1 --- a/inter_VMS_requests.h Fri Sep 16 20:13:33 2011 +0200 7.2 +++ b/inter_VMS_requests.h Mon Sep 19 14:15:37 2011 +0200 7.3 @@ -34,7 +34,8 @@ 7.4 //This ones for requests between internals of VMS-core.. such as malloc 7.5 enum InterVMSCoreReqType 7.6 { 7.7 - transfer_free_ptr = 1 //avoid starting enums at 0, for debug reasons 7.8 + transfer_free_ptr = 1, //avoid starting enums at 0, for debug reasons 7.9 + shutdownVP 7.10 }; 7.11 7.12 //Doing a trick to save space & time -- allocate space
8.1 --- a/inter_VMS_requests_handler.c Fri Sep 16 20:13:33 2011 +0200 8.2 +++ b/inter_VMS_requests_handler.c Mon Sep 19 14:15:37 2011 +0200 8.3 @@ -7,6 +7,7 @@ 8.4 #include <stdio.h> 8.5 #include <stdlib.h> 8.6 8.7 +#include "VMS.h" 8.8 #include "ProcrContext.h" 8.9 #include "inter_VMS_requests.h" 8.10 #include "vmalloc.h" 8.11 @@ -24,3 +25,17 @@ 8.12 VMS__free( masterReq->freePtr ); 8.13 } 8.14 8.15 + 8.16 +/* 8.17 + * The starts the shutdown procedure. 8.18 + */ 8.19 +inline void 8.20 +handleShutdown( InterVMSCoreReqst *masterReq, VirtProcr *masterPr ) 8.21 +{ 8.22 +#ifdef SEQUENTIAL 8.23 + asmTerminateCoreLoopSeq(masterPr); 8.24 +#else 8.25 + asmTerminateCoreLoop(masterPr); 8.26 +#endif 8.27 +} 8.28 +
9.1 --- a/inter_VMS_requests_handler.h Fri Sep 16 20:13:33 2011 +0200 9.2 +++ b/inter_VMS_requests_handler.h Mon Sep 19 14:15:37 2011 +0200 9.3 @@ -18,6 +18,9 @@ 9.4 inline void 9.5 handleTransferFree( InterVMSCoreReqst *masterReq, VirtProcr *masterPr ); 9.6 9.7 +inline void 9.8 +handleShutdown( InterVMSCoreReqst *masterReq, VirtProcr *masterPr ); 9.9 + 9.10 9.11 #endif /* _MASTER_REQ_HANDLER_H */ 9.12
10.1 --- a/vmalloc.c Fri Sep 16 20:13:33 2011 +0200 10.2 +++ b/vmalloc.c Mon Sep 19 14:15:37 2011 +0200 10.3 @@ -103,7 +103,7 @@ 10.4 } 10.5 10.6 if( foundElem == NULL ) 10.7 - { ERROR("\nmalloc failed\n") 10.8 + { ERROR1("\nMalloc failed, requested size: %d\n", sizeRequested); 10.9 return (void *)NULL; //indicates malloc failed 10.10 } 10.11 //Using a kludge to identify the element that is the top chunk in the
