Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 119:ac11b50220bd
Added inter-master requests
| author | Me@portablequad |
|---|---|
| date | Tue, 30 Aug 2011 21:55:04 -0700 |
| parents | 4700896a5666 |
| children | d4c881c7f03a 73acc2140742 |
| files | MasterLoop.c inter_VMS_request_handlers.c inter_VMS_request_handlers.h |
| diffstat | 3 files changed, 101 insertions(+), 11 deletions(-) [+] |
line diff
1.1 --- a/MasterLoop.c Tue Jul 26 16:28:47 2011 +0200 1.2 +++ b/MasterLoop.c Tue Aug 30 21:55:04 2011 -0700 1.3 @@ -11,7 +11,7 @@ 1.4 1.5 #include "VMS.h" 1.6 #include "ProcrContext.h" 1.7 - 1.8 +#include "Master_Request_Handlers.h" 1.9 1.10 //=========================================================================== 1.11 void inline 1.12 @@ -106,6 +106,8 @@ 1.13 1.14 1.15 //masterLoopStartPt: 1.16 + //The animating materVP suspends at end of this loop, then later resumes and 1.17 + // comes back here 1.18 while(1){ 1.19 1.20 //============================= MEASUREMENT STUFF ======================== 1.21 @@ -120,7 +122,7 @@ 1.22 masterEnv = (MasterEnv*)_VMSMasterEnv; 1.23 1.24 //GCC may optimize so doesn't always re-define from frame-storage 1.25 - masterPr = (VirtProcr*)volatileMasterPr; //just to make sure after jmp 1.26 + masterPr = (VirtProcr*)volatileMasterPr; //on stack, to be sure after jmp 1.27 thisCoresIdx = masterPr->coreAnimatedBy; 1.28 readyToAnimateQ = masterEnv->readyToAnimateQs[thisCoresIdx]; 1.29 schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; 1.30 @@ -129,8 +131,16 @@ 1.31 slaveScheduler = masterEnv->slaveScheduler; 1.32 semanticEnv = masterEnv->semanticEnv; 1.33 1.34 - 1.35 - //Poll each slot's Done flag 1.36 + //First, check for requests from other MasterVPs, and handle them 1.37 + if( masterEnv->requestsWaitingFor[thisCoresIdx] ) 1.38 + { masterReqQ = masterEnv->masterReqQs[thisCoresIdx]; 1.39 + while( currReq = readVMSQ(masterReqQ) ) 1.40 + { handleMasterReq( currReq, semanticEnv, masterPr ); 1.41 + } 1.42 + } 1.43 + //Now, take care of the SlaveVPs 1.44 + //Go through the slots -- if Slave there newly suspended, handle its request 1.45 + // then, either way, ask assigner to fill each slot 1.46 numSlotsFilled = 0; 1.47 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) 1.48 { 1.49 @@ -190,15 +200,44 @@ 1.50 1.51 masterSwitchToCoreLoop(animatingPr); 1.52 flushRegisters(); 1.53 - }//MasterLoop 1.54 - 1.55 - 1.56 + }//while(1) MasterLoop 1.57 } 1.58 1.59 +/*This is for inter-master communication. Either the master itself or 1.60 + * the plugin sends one of these requests. Some are handled here, by the 1.61 + * master_loop, others are handed off to the plugin. 1.62 + */ 1.63 +void inline 1.64 +handleMasterReq( MasterReq *currReq, void *_semEnv, VirtProcr *masterPr ) 1.65 + { 1.66 + switch( currReq->reqType ) 1.67 + { case interVMSReq: 1.68 + handleInterVMSReq( (InterVMSCoreReq *)currReq, masterPr); 1.69 + break; 1.70 + case interPluginReq: 1.71 + (*interPluginReqHdlr)( (InterPluginReq *)currReq, _semEnv ); 1.72 + break; 1.73 + default: 1.74 + break; 1.75 + } 1.76 + } 1.77 1.78 +void inline 1.79 +handleInterVMSReq( InterVMSCoreReq *currReq, VirtProcr *masterPr ) 1.80 + { 1.81 + switch( currReq->reqType ) 1.82 + { 1.83 + case transfer_free: handleTransferFree( currReq, masterPr ); 1.84 + break; 1.85 + } 1.86 + } 1.87 + 1.88 1.89 -/*This has a race condition -- the coreloops are accessing their own queues 1.90 - * at the same time that this work-stealer on a different core is trying to 1.91 +/*Work Stealing Alg -- racy one 1.92 + *This algorithm has a race condition -- the coreloops are accessing their 1.93 + * own queues at the same time that this work-stealer on a different core 1.94 + * is trying to. 1.95 + *The second stealing alg, below, protects against this. 1.96 */ 1.97 void inline 1.98 stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, 1.99 @@ -234,7 +273,8 @@ 1.100 } 1.101 } 1.102 1.103 -/*This algorithm makes the common case fast. Make the coreloop passive, 1.104 +/*Work Stealing alg -- protected one 1.105 + *This algorithm makes the common case fast. Make the coreloop passive, 1.106 * and show its progress. Make the stealer control a gate that coreloop 1.107 * has to pass. 1.108 *To avoid interference, only one stealer at a time. Use a global 1.109 @@ -360,7 +400,7 @@ 1.110 //======= End Gate-protection ======= 1.111 1.112 1.113 - if( stolenPr != NULL ) //victim could have been in protected and taken 1.114 + if( stolenPr != NULL ) //victim could have been in protected and took it 1.115 { currSlot->procrAssignedToSlot = stolenPr; 1.116 stolenPr->schedSlot = currSlot; 1.117 currSlot->needsProcrAssigned = FALSE;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/inter_VMS_request_handlers.c Tue Aug 30 21:55:04 2011 -0700 2.3 @@ -0,0 +1,27 @@ 2.4 +/* 2.5 + * Copyright 2011 OpenSourceCodeStewardshipFoundation 2.6 + * 2.7 + * Licensed under GNU GPL version 2 2.8 + */ 2.9 + 2.10 +#include <stdio.h> 2.11 +#include <stdlib.h> 2.12 + 2.13 +#include "VMS/VMS.h" 2.14 +#include "VMS/Queue_impl/PrivateQueue.h" 2.15 +#include "VMS/Hash_impl/PrivateHash.h" 2.16 +#include "VMS/vmalloc.h" 2.17 + 2.18 + 2.19 + 2.20 +//=============================== ================================= 2.21 +/*The VMS__free in a different masterVP discovered the chunk it was 2.22 + * given was originally allocated by this masterVP, so it sent the 2.23 + * chunk over. Simply call VMS__free here. 2.24 + */ 2.25 +inline void 2.26 +handleTransferFree( MasterReq *masterReq, VirtProcr *masterPr ) 2.27 + { 2.28 + VMS__free( masterReq->ptrToFree ); 2.29 + } 2.30 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/inter_VMS_request_handlers.h Tue Aug 30 21:55:04 2011 -0700 3.3 @@ -0,0 +1,23 @@ 3.4 +/* 3.5 + * Copyright 2011 OpenSourceStewardshipFoundation.org 3.6 + * Licensed under GNU General Public License version 2 3.7 + * 3.8 + * Author(s): seanhalle@yahoo.com 3.9 + * 3.10 + */ 3.11 + 3.12 +#ifndef _MASTER_REQ_H 3.13 +#define _MASTER_REQ_H 3.14 + 3.15 +/*Defines everything specific to inter-master requests that 3.16 + * are internal to VMS. 3.17 + *The plugin has its own handlers for inter-master requests 3.18 + * sent between plugin instances. 3.19 + */ 3.20 + 3.21 +inline void 3.22 +handleMakeMutex( VPThdSemReq *semReq, VPThdSemEnv *semEnv); 3.23 + 3.24 + 3.25 +#endif /* _MASTER_REQ_H */ 3.26 +
