changeset 135:0b49fd35afc1 Inter-Master Requests

distributed free working -app sends a VMSSemReqst to his Master which send a request to a different Master -Master send the request directly -The request structure is freed by the sender, when the request was handled There are still problems on shutdown. The shutdownVPs are all allocated by one Master which is likly to be terminated
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 16 Sep 2011 20:08:28 +0200
parents a9b72021f053
children f1374d5dbb98
files MasterLoop.c VMS.c VMS.h inter_VMS_request_handlers.c inter_VMS_request_handlers.h inter_VMS_requests.c inter_VMS_requests.h inter_VMS_requests_handler.c inter_VMS_requests_handler.h probes.c requests.h scheduling.h vmalloc.c vmalloc.h
diffstat 14 files changed, 280 insertions(+), 191 deletions(-) [+]
line diff
     1.1 --- a/MasterLoop.c	Fri Sep 16 16:19:24 2011 +0200
     1.2 +++ b/MasterLoop.c	Fri Sep 16 20:08:28 2011 +0200
     1.3 @@ -12,7 +12,8 @@
     1.4  #include "VMS.h"
     1.5  #include "ProcrContext.h"
     1.6  #include "scheduling.h"
     1.7 -#include "inter_VMS_request_handlers.h"
     1.8 +#include "inter_VMS_requests.h"
     1.9 +#include "inter_VMS_requests_handler.h"
    1.10  
    1.11  //===========================================================================
    1.12  void inline
    1.13 @@ -127,12 +128,23 @@
    1.14     semanticEnv      = masterEnv->semanticEnv;
    1.15  
    1.16        //First, check for requests from other MasterVPs, and handle them
    1.17 -   InterMasterReqst* currReq = masterEnv->interMasterRequestsFor[thisCoresIdx];
    1.18 -   while(currReq)
    1.19 +   InterMasterReqst* currReqst = masterEnv->interMasterRequestsFor[thisCoresIdx];
    1.20 +   while(currReqst)
    1.21     {
    1.22 -       handleInterMasterReq( currReq, semanticEnv, masterPr );
    1.23 -       currReq = currReq->nextReqst;
    1.24 +       handleInterMasterReq( currReqst, semanticEnv, masterPr );
    1.25 +       currReqst = currReqst->nextReqst;
    1.26     }
    1.27 +   masterEnv->interMasterRequestsFor[thisCoresIdx] = NULL;
    1.28 +   
    1.29 +   //Second, check for own request that were handled for other MasterVPs
    1.30 +   currReqst = masterEnv->interMasterRequestsSentBy[thisCoresIdx];
    1.31 +   while(currReqst && currReqst->obsolete)
    1.32 +   {
    1.33 +       InterMasterReqst *nextReqst = currReqst->nextSentReqst;
    1.34 +       VMS__free(currReqst);
    1.35 +       currReqst = nextReqst;
    1.36 +   }
    1.37 +   masterEnv->interMasterRequestsSentBy[thisCoresIdx] = currReqst;
    1.38     
    1.39        //Now, take care of the SlaveVPs
    1.40        //Go through the slots -- if Slave there newly suspended, handle its request
    1.41 @@ -228,8 +240,10 @@
    1.42   { 
    1.43     switch( currReq->reqType )
    1.44      {
    1.45 -      case transfer_free_ptr:    handleTransferFree( currReq, masterPr );
    1.46 -         break;
    1.47 +      case transfer_free_ptr:
    1.48 +          handleTransferFree( currReq, masterPr );
    1.49 +          currReq->obsolete = 1; //now the sender can free the structure
    1.50 +          break;
    1.51        default:
    1.52            break;
    1.53      }
     2.1 --- a/VMS.c	Fri Sep 16 16:19:24 2011 +0200
     2.2 +++ b/VMS.c	Fri Sep 16 20:08:28 2011 +0200
     2.3 @@ -111,6 +111,7 @@
     2.4     {
     2.5         _VMSMasterEnv->freeListHead[i]        = VMS_ext__create_free_list();
     2.6         _VMSMasterEnv->interMasterRequestsFor[i] = NULL;
     2.7 +       _VMSMasterEnv->interMasterRequestsSentBy[i] = NULL;
     2.8     }
     2.9     _VMSMasterEnv->currentMasterProcrID = 0;
    2.10  
    2.11 @@ -562,18 +563,27 @@
    2.12  
    2.13     semReq = req->semReqData;
    2.14  
    2.15 -   newProbe          = VMS__malloc( sizeof(IntervalProbe) );
    2.16 -   newProbe->nameStr = VMS__strDup( semReq->nameStr );
    2.17 -   newProbe->hist    = NULL;
    2.18 -   newProbe->schedChoiceWasRecorded = FALSE;
    2.19 +   switch(semReq->reqType){
    2.20 +       case createProbe:
    2.21 +           newProbe          = VMS__malloc( sizeof(IntervalProbe) );
    2.22 +           newProbe->nameStr = VMS__strDup( (char*)semReq->data );
    2.23 +           newProbe->hist    = NULL;
    2.24 +           newProbe->schedChoiceWasRecorded = FALSE;
    2.25  
    2.26 -      //This runs in masterVP, so no race-condition worries
    2.27 -   newProbe->probeID =
    2.28 -             addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo );
    2.29 -
    2.30 -   requestingPr->dataRetFromReq = newProbe;
    2.31 -
    2.32 -   (*resumePrFnPtr)( requestingPr, semEnv );
    2.33 +           //This runs in masterVP, so no race-condition worries
    2.34 +           newProbe->probeID =
    2.35 +                   addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo );
    2.36 +           requestingPr->dataRetFromReq = newProbe;
    2.37 +           break;
    2.38 +       case interMasterReqst:
    2.39 +           sendInterMasterReqst(semReq->receiverID,
    2.40 +                   (InterMasterReqst*)semReq->data);
    2.41 +           break;
    2.42 +       default:
    2.43 +           break;       
    2.44 +   }
    2.45 +   
    2.46 +   resumePrFnPtr( requestingPr, semEnv );
    2.47   }
    2.48  
    2.49  
    2.50 @@ -609,8 +619,13 @@
    2.51        // itself
    2.52        //Note, should not stack-allocate initial data -- no guarantee, in
    2.53        // general that creating processor will outlive ones it creates.
    2.54 -   VMS__free( animatingPr->startOfStack );
    2.55 -   VMS__free( animatingPr );
    2.56 +    
    2.57 +    
    2.58 +   /*
    2.59 +    * call the core specific version, because the creating master can already be dead
    2.60 +    */   
    2.61 +   //VMS__free_in_lib( animatingPr->startOfStack, animatingPr );
    2.62 +   //VMS__free_in_lib( animatingPr, animatingPr);
    2.63   }
    2.64  
    2.65  
    2.66 @@ -771,7 +786,9 @@
    2.67     //========================================================================
    2.68  */
    2.69        //These are the only two that use system free 
    2.70 -   VMS_ext__free_free_list( _VMSMasterEnv->freeListHead);
    2.71 +   int i;
    2.72 +   for(i=0; i<NUM_CORES; i++)
    2.73 +        VMS_ext__free_free_list( _VMSMasterEnv->freeListHead[i]);
    2.74     free( (void *)_VMSMasterEnv );
    2.75   }
    2.76  
     3.1 --- a/VMS.h	Fri Sep 16 16:19:24 2011 +0200
     3.2 +++ b/VMS.h	Fri Sep 16 20:08:28 2011 +0200
     3.3 @@ -18,7 +18,7 @@
     3.4  #include "DynArray/DynArray.h"
     3.5  #include "Hash_impl/PrivateHash.h"
     3.6  #include "vmalloc.h"
     3.7 -#include "requests.h"
     3.8 +#include "inter_VMS_requests.h"
     3.9  
    3.10  //===============================  Debug  ===================================
    3.11  //
    3.12 @@ -118,6 +118,48 @@
    3.13  typedef void  (*RequestHandler)  ( VirtProcr *, void * ); //prWReqst, semEnv
    3.14  typedef void  (*ResumePrFnPtr)   ( VirtProcr *, void * );
    3.15  
    3.16 +//============= Requests ===========
    3.17 +//
    3.18 +
    3.19 +//VMS Request is the carrier for Slave to Master requests
    3.20 +// it has an embedded sub-type request that is pulled out
    3.21 +// inside the plugin's request handler
    3.22 +enum VMSReqstType   //For Slave->Master requests
    3.23 + { 
    3.24 +   semantic = 1,    //avoid starting enums at 0, for debug reasons
    3.25 +   createReq,
    3.26 +   dissipate,
    3.27 +   VMSSemantic      //goes with VMSSemReqst below
    3.28 + };
    3.29 +
    3.30 +struct _VMSReqst
    3.31 + {
    3.32 +   enum VMSReqstType  reqType;//used for dissipate and in future for IO requests
    3.33 +   void              *semReqData;
    3.34 +
    3.35 +   VMSReqst *nextReqst;
    3.36 + };
    3.37 +//VMSReqst
    3.38 +
    3.39 +//This is a sub-type of Slave->Master requests.
    3.40 +// It's for Slaves to invoke built-in VMS-core functions that have language-like
    3.41 +// behavior.
    3.42 +enum VMSSemReqstType   //These are equivalent to semantic requests, but for
    3.43 + {                     // VMS's services available directly to app, like OS
    3.44 +   createProbe = 1,    // and probe services -- like a VMS-wide built-in lang
    3.45 +   openFile,
    3.46 +   otherIO,
    3.47 +   interMasterReqst
    3.48 + };
    3.49 +
    3.50 +typedef struct
    3.51 + { enum VMSSemReqstType reqType;
    3.52 +   //VirtProcr           *requestingPr;
    3.53 +   int                  receiverID; //for inter master requests
    3.54 +   void                *data;
    3.55 + }
    3.56 +VMSSemReq;
    3.57 +
    3.58  
    3.59  //====================  Core data structures  ===================
    3.60  
    3.61 @@ -149,6 +191,7 @@
    3.62     int32            workStealingLock;
    3.63     
    3.64     InterMasterReqst*  interMasterRequestsFor[NUM_CORES];
    3.65 +   InterMasterReqst*  interMasterRequestsSentBy[NUM_CORES];
    3.66     RequestHandler     interPluginReqHdlr;
    3.67     
    3.68     int32              numProcrsCreated; //gives ordering to processor creation
     4.1 --- a/inter_VMS_request_handlers.c	Fri Sep 16 16:19:24 2011 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,27 +0,0 @@
     4.4 -/*
     4.5 - * Copyright 2011  OpenSourceCodeStewardshipFoundation
     4.6 - *
     4.7 - * Licensed under GNU GPL version 2
     4.8 - */
     4.9 -
    4.10 -#include <stdio.h>
    4.11 -#include <stdlib.h>
    4.12 -
    4.13 -#include "VMS.h"
    4.14 -#include "Queue_impl/PrivateQueue.h"
    4.15 -#include "Hash_impl/PrivateHash.h"
    4.16 -#include "vmalloc.h"
    4.17 -
    4.18 -
    4.19 -
    4.20 -//===============================  =================================
    4.21 -/*The VMS__free in a different masterVP discovered the chunk it was
    4.22 - * given was originally allocated by this masterVP, so it sent the
    4.23 - * chunk over.  Simply call VMS__free here.
    4.24 - */
    4.25 -inline void
    4.26 -handleTransferFree( InterVMSCoreReqst *masterReq, VirtProcr *masterPr )
    4.27 - { 
    4.28 -   VMS__free( masterReq->freePtr );
    4.29 - }
    4.30 -
     5.1 --- a/inter_VMS_request_handlers.h	Fri Sep 16 16:19:24 2011 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,23 +0,0 @@
     5.4 -/*
     5.5 - *  Copyright 2011 OpenSourceStewardshipFoundation.org
     5.6 - *  Licensed under GNU General Public License version 2
     5.7 - *
     5.8 - * Author(s): seanhalle@yahoo.com
     5.9 - *
    5.10 - */
    5.11 -
    5.12 -#ifndef _MASTER_REQ_H
    5.13 -#define	_MASTER_REQ_H
    5.14 -
    5.15 -/*Defines everything specific to inter-master requests that
    5.16 - * are internal to VMS.
    5.17 - *The plugin has its own handlers for inter-master requests
    5.18 - * sent between plugin instances.
    5.19 - */
    5.20 -
    5.21 -inline void
    5.22 -handleTransferFree( InterVMSCoreReqst *masterReq, VirtProcr *masterPr );
    5.23 -
    5.24 -
    5.25 -#endif	/* _MASTER_REQ_H */
    5.26 -
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/inter_VMS_requests.c	Fri Sep 16 20:08:28 2011 +0200
     6.3 @@ -0,0 +1,15 @@
     6.4 +#include "VMS.h"
     6.5 +#include "inter_VMS_requests.h"
     6.6 +
     6.7 +
     6.8 +void sendInterMasterReqst(int procrID, InterMasterReqst* request)
     6.9 +{
    6.10 +    request->reqType = destVMSCore;
    6.11 +    request->obsolete = 0;
    6.12 +    request->nextReqst = _VMSMasterEnv->interMasterRequestsFor[procrID];
    6.13 +    _VMSMasterEnv->interMasterRequestsFor[procrID] = request;
    6.14 +    request->nextSentReqst = 
    6.15 +            _VMSMasterEnv->interMasterRequestsSentBy[_VMSMasterEnv->currentMasterProcrID];
    6.16 +    _VMSMasterEnv->interMasterRequestsSentBy[_VMSMasterEnv->currentMasterProcrID]
    6.17 +            = request;
    6.18 +}
    6.19 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/inter_VMS_requests.h	Fri Sep 16 20:08:28 2011 +0200
     7.3 @@ -0,0 +1,73 @@
     7.4 +/*
     7.5 + *  Copyright 2011 OpenSourceStewardshipFoundation.org
     7.6 + *  Licensed under GNU General Public License version 2
     7.7 + *
     7.8 + * Author(s): seanhalle@yahoo.com
     7.9 + *
    7.10 + */
    7.11 +
    7.12 +#ifndef _MASTER_REQ_H
    7.13 +#define	_MASTER_REQ_H
    7.14 +
    7.15 +typedef struct _InterMasterReqst InterMasterReqst;
    7.16 +
    7.17 +//These are for Master to Master requests
    7.18 +// They get re-cast to the appropriate sub-type of request
    7.19 +enum InterMasterReqstType    //For Master->Master
    7.20 + {
    7.21 +   destVMSCore = 1,          //avoid starting enums at 0, for debug reasons
    7.22 +   destPlugin
    7.23 + };
    7.24 +
    7.25 +struct _InterMasterReqst //Doing a trick to save space & time -- allocate
    7.26 + {  // space for a sub-type then cast first as InterMaster then as sub-type
    7.27 +   enum InterMasterReqstType  reqType;
    7.28 +   InterMasterReqst *nextReqst;
    7.29 +   InterMasterReqst *nextSentReqst;
    7.30 +   int32 obsolete;
    7.31 + };
    7.32 +//InterMasterReqst  (defined above in typedef block)
    7.33 +
    7.34 +
    7.35 +//These are a sub-type of InterMaster requests.  The inter-master req gets
    7.36 +// re-cast to be of this type, after checking
    7.37 +//This ones for requests between internals of VMS-core.. such as malloc
    7.38 +enum InterVMSCoreReqType   
    7.39 + {
    7.40 +   transfer_free_ptr = 1     //avoid starting enums at 0, for debug reasons
    7.41 + };
    7.42 +
    7.43 +//Doing a trick to save space & time -- allocate space
    7.44 +// for this, cast first as InterMaster then as this
    7.45 +typedef struct  
    7.46 + {
    7.47 +   enum InterMasterReqstType  reqType;  //duplicate InterMasterReqst at top
    7.48 +   InterMasterReqst *nextReqst;
    7.49 +   InterMasterReqst *nextSentReqst;
    7.50 +   int32 obsolete;
    7.51 +   
    7.52 +   enum InterVMSCoreReqType  secondReqType;
    7.53 +   void                     *freePtr;  //pile up fields, add as needed
    7.54 + } InterVMSCoreReqst;
    7.55 +
    7.56 +//This is for requests between plugins on different cores
    7.57 +// Here, after casting, the pluginReq is extracted and handed to plugin
    7.58 +//Doing a trick to save space & time -- allocate space
    7.59 +// for this, cast first as InterMaster then as this
    7.60 +typedef struct  
    7.61 + {
    7.62 +   enum InterMasterReqstType  reqType;  //copy InterMasterReqst at top
    7.63 +   InterMasterReqst          *nextReqst;
    7.64 +   
    7.65 +   void                      *pluginReq; //plugin will cast to approp type
    7.66 + } InterPluginReqst;
    7.67 + 
    7.68 + /*
    7.69 +  * This has to be called from the MasterLoop!
    7.70 +  * Send inter master request. The request structure has to be malloced itself.
    7.71 +  * The sending VP will free the structure when the request is handled.
    7.72 +  */
    7.73 + void sendInterMasterReqst(int procrID, InterMasterReqst* request);
    7.74 +
    7.75 +#endif	/* _MASTER_REQ_H */
    7.76 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/inter_VMS_requests_handler.c	Fri Sep 16 20:08:28 2011 +0200
     8.3 @@ -0,0 +1,26 @@
     8.4 +/*
     8.5 + * Copyright 2011  OpenSourceCodeStewardshipFoundation
     8.6 + *
     8.7 + * Licensed under GNU GPL version 2
     8.8 + */
     8.9 +
    8.10 +#include <stdio.h>
    8.11 +#include <stdlib.h>
    8.12 +
    8.13 +#include "ProcrContext.h"
    8.14 +#include "inter_VMS_requests.h"
    8.15 +#include "vmalloc.h"
    8.16 +
    8.17 +
    8.18 +
    8.19 +//==================================================================
    8.20 +/* The VMS__free in a different masterVP discovered the chunk it was
    8.21 + * given was originally allocated by this masterVP, so it sent the
    8.22 + * chunk over.  Simply call VMS__free here.
    8.23 + */
    8.24 +inline void
    8.25 +handleTransferFree( InterVMSCoreReqst *masterReq, VirtProcr *masterPr )
    8.26 + {
    8.27 +    VMS__free( masterReq->freePtr );
    8.28 + }
    8.29 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/inter_VMS_requests_handler.h	Fri Sep 16 20:08:28 2011 +0200
     9.3 @@ -0,0 +1,23 @@
     9.4 +/*
     9.5 + *  Copyright 2011 OpenSourceStewardshipFoundation.org
     9.6 + *  Licensed under GNU General Public License version 2
     9.7 + *
     9.8 + * Author(s): seanhalle@yahoo.com
     9.9 + *
    9.10 + */
    9.11 +
    9.12 +#ifndef _MASTER_REQ_HANDLER_H
    9.13 +#define	_MASTER_REQ_HANDLER_H
    9.14 +
    9.15 +/*Defines everything specific to inter-master requests that
    9.16 + * are internal to VMS.
    9.17 + *The plugin has its own handlers for inter-master requests
    9.18 + * sent between plugin instances.
    9.19 + */
    9.20 +
    9.21 +inline void
    9.22 +handleTransferFree( InterVMSCoreReqst *masterReq, VirtProcr *masterPr );
    9.23 +
    9.24 +
    9.25 +#endif	/* _MASTER_REQ_HANDLER_H */
    9.26 +
    10.1 --- a/probes.c	Fri Sep 16 16:19:24 2011 +0200
    10.2 +++ b/probes.c	Fri Sep 16 20:08:28 2011 +0200
    10.3 @@ -113,7 +113,7 @@
    10.4     VMSSemReq reqData;
    10.5  
    10.6     reqData.reqType  = createProbe;
    10.7 -   reqData.nameStr  = nameStr;
    10.8 +   reqData.data  = (void*)nameStr;
    10.9  
   10.10     VMS__send_VMSSem_request( &reqData, animPr );
   10.11  
    11.1 --- a/requests.h	Fri Sep 16 16:19:24 2011 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,103 +0,0 @@
    11.4 -/* 
    11.5 - * File:   requests.h
    11.6 - * Author: msach
    11.7 - *
    11.8 - * Created on September 16, 2011, 3:11 PM
    11.9 - */
   11.10 -
   11.11 -#ifndef REQUESTS_H
   11.12 -#define	REQUESTS_H
   11.13 -
   11.14 -#include "ProcrContext.h"
   11.15 -
   11.16 -typedef struct _InterMasterReqst InterMasterReqst;
   11.17 -
   11.18 -//============= Requests ===========
   11.19 -//
   11.20 -
   11.21 -//VMS Request is the carrier for Slave to Master requests
   11.22 -// it has an embedded sub-type request that is pulled out
   11.23 -// inside the plugin's request handler
   11.24 -enum VMSReqstType   //For Slave->Master requests
   11.25 - { 
   11.26 -   semantic = 1,    //avoid starting enums at 0, for debug reasons
   11.27 -   createReq,
   11.28 -   dissipate,
   11.29 -   VMSSemantic      //goes with VMSSemReqst below
   11.30 - };
   11.31 -
   11.32 -struct _VMSReqst
   11.33 - {
   11.34 -   enum VMSReqstType  reqType;//used for dissipate and in future for IO requests
   11.35 -   void              *semReqData;
   11.36 -
   11.37 -   VMSReqst *nextReqst;
   11.38 - };
   11.39 -//VMSReqst
   11.40 -
   11.41 -//This is a sub-type of Slave->Master requests.
   11.42 -// It's for Slaves to invoke built-in VMS-core functions that have language-like
   11.43 -// behavior.
   11.44 -enum VMSSemReqstType   //These are equivalent to semantic requests, but for
   11.45 - {                     // VMS's services available directly to app, like OS
   11.46 -   createProbe = 1,    // and probe services -- like a VMS-wide built-in lang
   11.47 -   openFile,
   11.48 -   otherIO
   11.49 - };
   11.50 -
   11.51 -typedef struct
   11.52 - { enum VMSSemReqstType reqType;
   11.53 -   VirtProcr           *requestingPr;
   11.54 -   char                *nameStr;  //for create probe
   11.55 - }
   11.56 -VMSSemReq;
   11.57 -
   11.58 -//These are for Master to Master requests
   11.59 -// They get re-cast to the appropriate sub-type of request
   11.60 -enum InterMasterReqstType    //For Master->Master
   11.61 - {
   11.62 -   destVMSCore = 1,          //avoid starting enums at 0, for debug reasons
   11.63 -   destPlugin
   11.64 - };
   11.65 -
   11.66 -struct _InterMasterReqst //Doing a trick to save space & time -- allocate
   11.67 - {  // space for a sub-type then cast first as InterMaster then as sub-type
   11.68 -   enum InterMasterReqstType  reqType;
   11.69 -   InterMasterReqst *nextReqst;
   11.70 - };
   11.71 -//InterMasterReqst  (defined above in typedef block)
   11.72 -
   11.73 -
   11.74 -//These are a sub-type of InterMaster requests.  The inter-master req gets
   11.75 -// re-cast to be of this type, after checking
   11.76 -//This ones for requests between internals of VMS-core.. such as malloc
   11.77 -enum InterVMSCoreReqType   
   11.78 - {
   11.79 -   transfer_free_ptr = 1     //avoid starting enums at 0, for debug reasons
   11.80 - };
   11.81 -
   11.82 -//Doing a trick to save space & time -- allocate space
   11.83 -// for this, cast first as InterMaster then as this
   11.84 -typedef struct  
   11.85 - {
   11.86 -   enum InterMasterReqstType  reqType;  //duplicate InterMasterReqst at top
   11.87 -   InterMasterReqst *nextReqst;
   11.88 -   
   11.89 -   enum InterVMSCoreReqType  secondReqType;
   11.90 -   void                     *freePtr;  //pile up fields, add as needed
   11.91 - } InterVMSCoreReqst;
   11.92 -
   11.93 -//This is for requests between plugins on different cores
   11.94 -// Here, after casting, the pluginReq is extracted and handed to plugin
   11.95 -//Doing a trick to save space & time -- allocate space
   11.96 -// for this, cast first as InterMaster then as this
   11.97 -typedef struct  
   11.98 - {
   11.99 -   enum InterMasterReqstType  reqType;  //copy InterMasterReqst at top
  11.100 -   InterMasterReqst          *nextReqst;
  11.101 -   
  11.102 -   void                      *pluginReq; //plugin will cast to approp type
  11.103 - } InterPluginReqst;
  11.104 -
  11.105 -#endif	/* REQUESTS_H */
  11.106 -
    12.1 --- a/scheduling.h	Fri Sep 16 16:19:24 2011 +0200
    12.2 +++ b/scheduling.h	Fri Sep 16 20:08:28 2011 +0200
    12.3 @@ -1,6 +1,6 @@
    12.4  /* 
    12.5   * File:   scheduling.h
    12.6 - * Author: msach
    12.7 + * Author: Merten Sachh
    12.8   *
    12.9   * Created on September 16, 2011, 2:28 PM
   12.10   */
    13.1 --- a/vmalloc.c	Fri Sep 16 16:19:24 2011 +0200
    13.2 +++ b/vmalloc.c	Fri Sep 16 20:08:28 2011 +0200
    13.3 @@ -15,6 +15,12 @@
    13.4  #include "VMS.h"
    13.5  #include "Histogram/Histogram.h"
    13.6  
    13.7 +inline void
    13.8 +sendFreeReqst_lib(int receiverID, void *ptrToFree, VirtProcr *animPr);
    13.9 +
   13.10 +inline void
   13.11 +sendFreeReqst_master(int receiverID, void *ptrToFree);
   13.12 +
   13.13  /*Helper function
   13.14   *Insert a newly generated free chunk into the first spot on the free list.
   13.15   * The chunk is cast as a MallocProlog, so the various pointers in it are
   13.16 @@ -70,8 +76,6 @@
   13.17     MallocPrologAllocated *returnElem;
   13.18     ssize_t        amountExtra, sizeConsumed,sizeOfFound;
   13.19     uint32        foundElemIsTopOfHeap;
   13.20 -   
   13.21 -   printf("Malloc on core %d\n", procrID);
   13.22  
   13.23     //============================= MEASUREMENT STUFF ========================
   13.24     #ifdef MEAS__TIME_MALLOC
   13.25 @@ -167,7 +171,8 @@
   13.26      }
   13.27      else
   13.28      {
   13.29 -        //Request from other Core
   13.30 +        sendFreeReqst_master(chunk->procrID, ptrToFree);
   13.31 +        
   13.32      }
   13.33  }
   13.34  
   13.35 @@ -180,17 +185,49 @@
   13.36  VMS__free_in_lib(void *ptrToFree, VirtProcr *VProc)
   13.37  {
   13.38      MallocPrologAllocated *chunk = (MallocPrologAllocated*)ptrToFree - 1;
   13.39 -    printf("Free from core %d for core %d\n", VProc->coreAnimatedBy, chunk->procrID);
   13.40      if(chunk->procrID == VProc->coreAnimatedBy)
   13.41      {
   13.42          VMS__free_on_core(ptrToFree, VProc->coreAnimatedBy);
   13.43      }
   13.44      else
   13.45      {
   13.46 -        //Request from other Core
   13.47 +        sendFreeReqst_lib(chunk->procrID, ptrToFree, VProc);
   13.48      }
   13.49  }
   13.50  
   13.51 +/* 
   13.52 + * This is called form a masterVP and request an free from a different masterVP.
   13.53 + * The free of the request structure is done after the request is handled.
   13.54 + */
   13.55 +inline void
   13.56 +sendFreeReqst_master(int receiverID, void *ptrToFree)
   13.57 +{
   13.58 +   InterVMSCoreReqst *freeReqst = VMS__malloc(sizeof(InterVMSCoreReqst));
   13.59 +   freeReqst->freePtr = ptrToFree;
   13.60 +   freeReqst->secondReqType = transfer_free_ptr;
   13.61 +
   13.62 +   sendInterMasterReqst(receiverID, (InterMasterReqst*)freeReqst);
   13.63 + }
   13.64 +
   13.65 +/*
   13.66 + * This is called if the free is called from the plugin. This requests an inter
   13.67 + * master request from his master.
   13.68 + */
   13.69 +inline void
   13.70 +sendFreeReqst_lib(int receiverID, void *ptrToFree, VirtProcr *animPr )
   13.71 +{
   13.72 +   VMSSemReq reqData;
   13.73 +   InterVMSCoreReqst *freeReqst = VMS__malloc(sizeof(InterVMSCoreReqst));
   13.74 +   freeReqst->freePtr = ptrToFree;
   13.75 +   freeReqst->secondReqType = transfer_free_ptr;
   13.76 +
   13.77 +   reqData.reqType  = interMasterReqst;
   13.78 +   reqData.receiverID   = receiverID;
   13.79 +   reqData.data  = (void*)freeReqst;
   13.80 +
   13.81 +   VMS__send_VMSSem_request( (void*)&reqData, animPr );
   13.82 + }
   13.83 +
   13.84  /*This is sequential code -- only to be called from the Master
   13.85   * When free, subtract the size of prolog from pointer, then cast it to a
   13.86   * MallocProlog.  Then check the nextLower and nextHigher chunks to see if
   13.87 @@ -367,8 +404,6 @@
   13.88   {
   13.89        //just risk system-stack faults until get this figured out
   13.90     free( ptrToFree );
   13.91 -
   13.92 -      //TODO: fix this -- so 
   13.93   }
   13.94  
   13.95  
   13.96 @@ -418,15 +453,11 @@
   13.97  /*Designed to be called from the main thread outside of VMS, during cleanup
   13.98   */
   13.99  void
  13.100 -VMS_ext__free_free_list( MallocProlog* freeListHeads[] )
  13.101 +VMS_ext__free_free_list( MallocProlog* freeListHead)
  13.102   {    
  13.103        //stashed a ptr to the one and only bug chunk malloc'd from OS in the
  13.104        // free list head's next lower in mem pointer
  13.105 -    int i;
  13.106 -    for(i=0; i<NUM_CORES; i++)
  13.107 -    {
  13.108 -        free( freeListHeads[i]->nextLowerInMem );
  13.109 -    }
  13.110 +    free( freeListHead->nextLowerInMem );
  13.111     //don't free the head -- it'll be in an array eventually -- free whole
  13.112     // array when all the free lists linked from it have already been freed
  13.113   }
    14.1 --- a/vmalloc.h	Fri Sep 16 16:19:24 2011 +0200
    14.2 +++ b/vmalloc.h	Fri Sep 16 20:08:28 2011 +0200
    14.3 @@ -71,6 +71,6 @@
    14.4  VMS_ext__create_free_list();
    14.5  
    14.6  void
    14.7 -VMS_ext__free_free_list( MallocProlog* freeListHeads[] );
    14.8 +VMS_ext__free_free_list( MallocProlog* freeListHead );
    14.9  
   14.10  #endif
   14.11 \ No newline at end of file