changeset 14:b2bc97318262 dev_expl_VP_and_DKU

bug fix -- always turn SlotTaskSlv into ExtraTaskSlv inside request handler
author Sean Halle <seanhalle@yahoo.com>
date Thu, 23 Aug 2012 01:27:26 -0700
parents 2bf83f932705
children 459055db7fc0
files VSs.h VSs_Request_Handlers.c VSs_Request_Handlers.h
diffstat 3 files changed, 73 insertions(+), 58 deletions(-) [+]
line diff
     1.1 --- a/VSs.h	Tue Aug 21 17:42:07 2012 +0200
     1.2 +++ b/VSs.h	Thu Aug 23 01:27:26 2012 -0700
     1.3 @@ -229,11 +229,11 @@
     1.4   
     1.5  typedef struct
     1.6   {
     1.7 -   int32          highestTransEntered;
     1.8 -   TransListElem *lastTransEntered;
     1.9 -   bool32         needsTaskAssigned;
    1.10 -   VSsTaskStub   *taskStub;
    1.11 -   enum VSsSlvType     slaveType;
    1.12 +   int32           highestTransEntered;
    1.13 +   TransListElem  *lastTransEntered;
    1.14 +   bool32          needsTaskAssigned;
    1.15 +   VSsTaskStub    *taskStub;
    1.16 +   enum VSsSlvType slaveType;
    1.17   }
    1.18  VSsSemData;
    1.19   
     2.1 --- a/VSs_Request_Handlers.c	Tue Aug 21 17:42:07 2012 +0200
     2.2 +++ b/VSs_Request_Handlers.c	Thu Aug 23 01:27:26 2012 -0700
     2.3 @@ -227,7 +227,10 @@
     2.4     HashTable *
     2.5     argPtrHashTbl = semEnv->argPtrHashTbl;
     2.6     
     2.7 -         DEBUG__printf1(dbgRqstHdlr,"Submit request from processor %d",semReq->callingSlv->slaveID)
     2.8 +      //suspending a task always makes the slave into an extra slot slave,
     2.9 +      // because it ends up in the resumeQ, even when resumes immediately.
    2.10 +      //Eventually task_end will put the slave into the freeExtraTaskSlvQ
    2.11 +   replaceWithNewSlotSlvIfNeeded( semReq->callingSlv, semEnv );
    2.12   
    2.13     /* ==========================  creation  ========================== 
    2.14      * 
    2.15 @@ -248,6 +251,9 @@
    2.16     taskStub->parentTaskStub = (void*) parentSemData->taskStub;
    2.17     parentSemData->taskStub->numLiveChildTasks += 1;
    2.18     
    2.19 +         //DEBUG__printf3(dbgRqstHdlr,"Submit req from slaveID: %d, from task: %d, for task: %d", semReq->callingSlv->slaveID, parentSemData->taskStub->taskID[1], taskStub->taskID[1])
    2.20 +         DEBUG__printf2(dbgRqstHdlr,"Submit req from slaveID: %d, for task: %d", semReq->callingSlv->slaveID, taskStub->taskID[1])
    2.21 +          
    2.22     /*The controlled arguments are then processed one by one.
    2.23      *Processing an argument means getting the hash of the pointer.  Then,
    2.24      * looking up the hash entry.  (If none, create one).
    2.25 @@ -375,7 +381,6 @@
    2.26     VSsTaskStubCarrier *waitingTaskCarrier;
    2.27     VSsPointerEntry **ptrEntries;
    2.28           
    2.29 -         DEBUG__printf1(dbgRqstHdlr,"EndTask request from processor %d",semReq->callingSlv->slaveID)
    2.30   
    2.31     endingSlvSemData = (VSsSemData *)semReq->callingSlv->semanticData;
    2.32     endingTaskStub   = endingSlvSemData->taskStub;
    2.33 @@ -383,6 +388,8 @@
    2.34     endingTaskType   = endingTaskStub->taskType;
    2.35     ptrEntries       = endingTaskStub->ptrEntries; //saved in stub when create
    2.36     
    2.37 +         DEBUG__printf2(dbgRqstHdlr,"EndTask req from slaveID: %d, task: %d",semReq->callingSlv->slaveID, endingTaskStub->taskID[1])
    2.38 +          
    2.39        //Check if parent was waiting on this task
    2.40     parent = (VSsTaskStub *) endingTaskStub->parentTaskStub;
    2.41     parent->numLiveChildTasks -= 1;
    2.42 @@ -525,11 +532,10 @@
    2.43  
    2.44  inline void
    2.45  free_task_stub( VSsTaskStub *stubToFree )
    2.46 -{ 
    2.47 -    if(stubToFree->ptrEntries){
    2.48 -        VMS_PI__free( stubToFree->ptrEntries );
    2.49 + { if(stubToFree->ptrEntries != NULL ) //a thread stub has NULL entry
    2.50 +    { VMS_PI__free( stubToFree->ptrEntries );
    2.51      }
    2.52 -    VMS_PI__free( stubToFree );
    2.53 +   VMS_PI__free( stubToFree );
    2.54   }
    2.55  
    2.56  //========================== Task Comm handlers ===========================
    2.57 @@ -556,25 +562,26 @@
    2.58     HashEntry  *entry;
    2.59     HashTable  *commHashTbl = semEnv->commHashTbl;
    2.60     
    2.61 -         DEBUG__printf1(dbgRqstHdlr,"SendType request from processor %d",semReq->senderSlv->slaveID)
    2.62 - 
    2.63     receiverID  = semReq->receiverID; //For "send", know both send & recv procrs
    2.64     senderSlv   = semReq->senderSlv;
    2.65  
    2.66 +         DEBUG__printf2(dbgRqstHdlr,"SendType req from sender slaveID: %d, recTask: %d", senderSlv->slaveID, receiverID[1])
    2.67 +          
    2.68 +      //suspending a task always makes the slave into an extra slot slave,
    2.69 +      // because it ends up in the resumeQ, even when resumes immediately.
    2.70 +      //Eventually task_end will put the slave into the freeExtraTaskSlvQ
    2.71 +   replaceWithNewSlotSlvIfNeeded( senderSlv, semEnv );
    2.72 +         
    2.73     receiverIDNumInt = receiverID[0] + 1; //pos 0 doesn't include itself
    2.74 -   keySz = receiverIDNumInt * sizeof(int32) + sizeof(int32);
    2.75 +   keySz = receiverIDNumInt * sizeof(int32) + 2 * sizeof(int32);
    2.76     key = VMS_PI__malloc( keySz );
    2.77 -   memcpy( key, receiverID, receiverIDNumInt * sizeof(int32) );
    2.78 -   key[ receiverIDNumInt ] = semReq->msgType; //no +1 'cause starts at 0
    2.79 +   key[0] = receiverIDNumInt + 1; //loc 0 is num int32 in key
    2.80 +   memcpy( &key[1], receiverID, receiverIDNumInt * sizeof(int32) );
    2.81 +   key[ 1 + receiverIDNumInt ] = semReq->msgType; 
    2.82     
    2.83     entry = giveEntryElseInsertReqst32( key, semReq, commHashTbl );
    2.84     if( entry == NULL ) //was just inserted, means task has to wait
    2.85 -    {    //the task is in a slot slave, which stays suspended, so replace
    2.86 -         // it with a new slave (causes it to become an extraTaskSlv)
    2.87 -         //Once the waiting slave resumes and gets to task_end, the task_end
    2.88 -         // puts the slave into the freeExtraTaskSlvQ
    2.89 -      replaceWithNewSlotSlv( senderSlv, semEnv );
    2.90 -      return;
    2.91 +    { return;
    2.92      }
    2.93  
    2.94        //if here, found a waiting request with same key
    2.95 @@ -659,28 +666,29 @@
    2.96     HashEntry   *entry;
    2.97     HashTable   *commHashTbl = semEnv->commHashTbl;
    2.98  
    2.99 -         DEBUG__printf2(dbgRqstHdlr,"SendFromTo request from processor %d to %d",
   2.100 +         DEBUG__printf2(dbgRqstHdlr,"SendFromTo req from task %d to %d",
   2.101                          semReq->senderID[1],semReq->receiverID[1])
   2.102     
   2.103     receiverID  = semReq->receiverID; //For "send", know both send & recv procrs
   2.104     senderID    = semReq->senderID;
   2.105     senderSlv   = semReq->senderSlv;
   2.106  
   2.107 -   receiverIDNumInt = receiverID[0] + 1; //pos 0 doesn't include itself
   2.108 +      //suspending a task always makes the slave into an extra slot slave,
   2.109 +      // because it ends up in the resumeQ, even when resumes immediately.
   2.110 +      //Eventually task_end will put the slave into the freeExtraTaskSlvQ
   2.111 +   replaceWithNewSlotSlvIfNeeded( senderSlv, semEnv );
   2.112 +   
   2.113 +   receiverIDNumInt = receiverID[0] + 1; //include the count in the key
   2.114     senderIDNumInt   = senderID[0] + 1;
   2.115 -   keySz = (receiverIDNumInt + senderIDNumInt) * sizeof(int32);
   2.116 +   keySz = (receiverIDNumInt + senderIDNumInt) * sizeof(int32) + sizeof(int32);
   2.117     key   = VMS_PI__malloc( keySz );
   2.118 -   memcpy(  key, receiverID, receiverIDNumInt * sizeof(int32) );
   2.119 -   memcpy( &key[receiverIDNumInt], senderID, senderIDNumInt * sizeof(int32) );
   2.120 +   key[0] = receiverIDNumInt + senderIDNumInt;
   2.121 +   memcpy( &key[1], receiverID, receiverIDNumInt * sizeof(int32) );
   2.122 +   memcpy( &key[1 + receiverIDNumInt], senderID, senderIDNumInt * sizeof(int32) );
   2.123  
   2.124     entry = giveEntryElseInsertReqst32( key, semReq, commHashTbl );
   2.125     if( entry == NULL ) //was just inserted, means task has to wait
   2.126 -    {    //the task is in a slot slave, which stays suspended, so replace
   2.127 -         // it with a new slave (causes it to become an extraTaskSlv)
   2.128 -         //Once the waiting slave resumes and gets to task_end, the task_end
   2.129 -         // puts the slave into the freeExtraTaskSlvQ
   2.130 -      replaceWithNewSlotSlv( senderSlv, semEnv );
   2.131 -      return;
   2.132 +    { return;
   2.133      }
   2.134  
   2.135     waitingReq = (VSsSemReq *)entry->content;
   2.136 @@ -742,27 +750,27 @@
   2.137     HashEntry  *entry;
   2.138     HashTable  *commHashTbl = semEnv->commHashTbl;
   2.139     
   2.140 -         DEBUG__printf1(dbgRqstHdlr,"SendType request to %d",semReq->receiverID[1])
   2.141 +         DEBUG__printf2(dbgRqstHdlr,"ReceiveType req to ID: %d type: %d",semReq->receiverID[1], semReq->msgType)
   2.142   
   2.143     receiverID  = semReq->receiverID; //For "send", know both send & recv procrs
   2.144     receiverSlv = semReq->receiverSlv;
   2.145 +   
   2.146 +      //suspending a task always makes the slave into an extra slot slave,
   2.147 +      // because it ends up in the resumeQ, even when resumes immediately.
   2.148 +      //Eventually task_end will put the slave into the freeExtraTaskSlvQ
   2.149 +   replaceWithNewSlotSlvIfNeeded( receiverSlv, semEnv );
   2.150  
   2.151        //key is the receiverID plus the type -- have to copy them into key
   2.152     receiverIDNumInt = receiverID[0] + 1; //pos 0 doesn't include itself
   2.153 -   keySz = receiverIDNumInt * sizeof(int32) + sizeof(int32);
   2.154 +   keySz = receiverIDNumInt * sizeof(int32) + 2 * sizeof(int32);
   2.155     key = VMS_PI__malloc( keySz );
   2.156 -   memcpy( key, receiverID, receiverIDNumInt * sizeof(int32) );
   2.157 -   key[ receiverIDNumInt ] = semReq->msgType; //no +1 'cause starts at 0
   2.158 -
   2.159 +   key[0] = receiverIDNumInt + 1; //loc 0 is num int32s in key
   2.160 +   memcpy( &key[1], receiverID, receiverIDNumInt * sizeof(int32) );
   2.161 +   key[ 1 + receiverIDNumInt ] = semReq->msgType; 
   2.162  
   2.163     entry = giveEntryElseInsertReqst32( key, semReq, commHashTbl );//clones
   2.164     if( entry == NULL ) //was just inserted, means task has to wait
   2.165 -    {    //the task is in a slot slave, which stays suspended, so replace
   2.166 -         // it with a new slave (causes it to become an extraTaskSlv)
   2.167 -         //Once the waiting slave resumes and gets to task_end, the task_end
   2.168 -         // puts the slave into the freeExtraTaskSlvQ
   2.169 -      replaceWithNewSlotSlv( receiverSlv, semEnv );
   2.170 -      return;
   2.171 +    { return;
   2.172      }
   2.173  
   2.174     waitingReq = (VSsSemReq *)entry->content;  //previously cloned by insert
   2.175 @@ -831,27 +839,28 @@
   2.176     HashEntry   *entry;
   2.177     HashTable   *commHashTbl = semEnv->commHashTbl;
   2.178  
   2.179 -         DEBUG__printf2(dbgRqstHdlr,"ReceiveFromTo request from %d to %d",semReq->senderID[1],semReq->receiverID[1])
   2.180 +         DEBUG__printf2(dbgRqstHdlr,"RecFromTo req from ID: %d to ID: %d",semReq->senderID[1],semReq->receiverID[1])
   2.181     
   2.182     receiverID  = semReq->receiverID; //For "send", know both send & recv procrs
   2.183     senderID    = semReq->senderID;
   2.184     receiverSlv = semReq->receiverSlv;
   2.185 +   
   2.186 +      //suspending a task always makes the slave into an extra slot slave,
   2.187 +      // because it ends up in the resumeQ, even when resumes immediately.
   2.188 +      //Eventually task_end will put the slave into the freeExtraTaskSlvQ
   2.189 +   replaceWithNewSlotSlvIfNeeded( receiverSlv, semEnv );
   2.190  
   2.191     receiverIDNumInt = receiverID[0] + 1; //pos 0 doesn't include itself
   2.192     senderIDNumInt   = senderID[0] + 1;
   2.193 -   keySz = (receiverIDNumInt + senderIDNumInt) * sizeof(int32);
   2.194 +   keySz = (receiverIDNumInt + senderIDNumInt) * sizeof(int32) + sizeof(int32);
   2.195     key = VMS_PI__malloc( keySz );
   2.196 -   memcpy(  key, receiverID, receiverIDNumInt * sizeof(int32) );
   2.197 -   memcpy( &key[receiverIDNumInt], senderID, senderIDNumInt * sizeof(int32));
   2.198 +   key[0] = receiverIDNumInt + senderIDNumInt; //loc 0 is num int32s in key
   2.199 +   memcpy( &key[1], receiverID, receiverIDNumInt * sizeof(int32) );
   2.200 +   memcpy( &key[1 + receiverIDNumInt], senderID, senderIDNumInt * sizeof(int32));
   2.201  
   2.202     entry = giveEntryElseInsertReqst32( key, semReq, commHashTbl );
   2.203     if( entry == NULL ) //was just inserted, means task has to wait
   2.204 -    {    //the task is in a slot slave, which stays suspended, so replace
   2.205 -         // it with a new slave (causes it to become an extraTaskSlv)
   2.206 -         //Once the waiting slave resumes and gets to task_end, the task_end
   2.207 -         // puts the slave into the freeExtraTaskSlvQ
   2.208 -      replaceWithNewSlotSlv( receiverSlv, semEnv );
   2.209 -      return;
   2.210 +    { return;
   2.211      }
   2.212  
   2.213     waitingReq = (VSsSemReq *)entry->content;
   2.214 @@ -894,10 +903,14 @@
   2.215  
   2.216  //==========================================================================
   2.217  inline void
   2.218 -replaceWithNewSlotSlv( SlaveVP *requestingSlv, VSsSemEnv *semEnv )
   2.219 +replaceWithNewSlotSlvIfNeeded( SlaveVP *requestingSlv, VSsSemEnv *semEnv )
   2.220   { SlaveVP *newSlotSlv;
   2.221 -   VSsSemData *semData;
   2.222 +   VSsSemData *semData, *reqSemData;
   2.223  
   2.224 +   reqSemData = (VSsSemData *)requestingSlv->semanticData;
   2.225 +   if( reqSemData->slaveType != SlotTaskSlv )
   2.226 +      return; //already replaced, so just return
   2.227 +   
   2.228        //get a new slave to be the slot slave
   2.229     newSlotSlv     = readPrivQ( semEnv->freeExtraTaskSlvQ );
   2.230     if( newSlotSlv == NULL )
   2.231 @@ -909,6 +922,8 @@
   2.232     semData->taskStub              = NULL;
   2.233     semData->slaveType             = SlotTaskSlv;
   2.234     semData->needsTaskAssigned     = TRUE;
   2.235 +   
   2.236 +      //a slot slave is pinned to a particular slot on a particular core
   2.237     newSlotSlv->animSlotAssignedTo = requestingSlv->animSlotAssignedTo;
   2.238     newSlotSlv->coreAnimatedBy     = requestingSlv->coreAnimatedBy;
   2.239      
   2.240 @@ -940,7 +955,7 @@
   2.241     else  //have to wait, replace requester with new slot slv & mark waiting
   2.242      { 
   2.243         if(semData->slaveType == SlotTaskSlv){
   2.244 -         replaceWithNewSlotSlv( requestingSlv, semEnv );
   2.245 +         replaceWithNewSlotSlvIfNeeded( requestingSlv, semEnv );
   2.246         }
   2.247         
   2.248        requestingTaskStub->isWaitingForChildTasksToEnd = TRUE;
     3.1 --- a/VSs_Request_Handlers.h	Tue Aug 21 17:42:07 2012 +0200
     3.2 +++ b/VSs_Request_Handlers.h	Thu Aug 23 01:27:26 2012 -0700
     3.3 @@ -55,7 +55,7 @@
     3.4  inline void
     3.5  free_task_stub( VSsTaskStub *stubToFree );
     3.6  inline void
     3.7 -replaceWithNewSlotSlv( SlaveVP *requestingSlv, VSsSemEnv *semEnv );
     3.8 +replaceWithNewSlotSlvIfNeeded( SlaveVP *requestingSlv, VSsSemEnv *semEnv );
     3.9  
    3.10  
    3.11  #endif	/* _VSs_REQ_H */