diff VMS.h @ 120:d4c881c7f03a

Added fn to send inter-master requests, and cleaned up code
author Me@portablequad
date Sat, 03 Sep 2011 20:41:51 -0700
parents efb55f1b5fb9
children 24466227d8bb
line diff
     1.1 --- a/VMS.h	Tue Aug 30 21:55:04 2011 -0700
     1.2 +++ b/VMS.h	Sat Sep 03 20:41:51 2011 -0700
     1.3 @@ -113,7 +113,7 @@
     1.4  
     1.5  typedef struct _SchedSlot     SchedSlot;
     1.6  typedef struct _VMSReqst      VMSReqst;
     1.7 -typedef struct _VirtProcr     VirtProcr;
     1.8 +typedef struct _InterMasterReqst InterMasterReqst;
     1.9  typedef struct _IntervalProbe IntervalProbe;
    1.10  typedef struct _GateStruc     GateStruc;
    1.11  
    1.12 @@ -128,9 +128,12 @@
    1.13  //============= Requests ===========
    1.14  //
    1.15  
    1.16 -enum VMSReqstType   //avoid starting enums at 0, for debug reasons
    1.17 - {
    1.18 -   semantic = 1,
    1.19 +//VMS Request is the carrier for Slave to Master requests
    1.20 +// it has an embedded sub-type request that is pulled out
    1.21 +// inside the plugin's request handler
    1.22 +enum VMSReqstType   //For Slave->Master requests
    1.23 + { 
    1.24 +   semantic = 1,    //avoid starting enums at 0, for debug reasons
    1.25     createReq,
    1.26     dissipate,
    1.27     VMSSemantic      //goes with VMSSemReqst below
    1.28 @@ -145,6 +148,9 @@
    1.29   };
    1.30  //VMSReqst
    1.31  
    1.32 +//This is a sub-type of Slave->Master requests.
    1.33 +// It's for Slaves to invoke built-in VMS-core functions that have language-like
    1.34 +// behavior.
    1.35  enum VMSSemReqstType   //These are equivalent to semantic requests, but for
    1.36   {                     // VMS's services available directly to app, like OS
    1.37     createProbe = 1,    // and probe services -- like a VMS-wide built-in lang
    1.38 @@ -157,7 +163,53 @@
    1.39     VirtProcr           *requestingPr;
    1.40     char                *nameStr;  //for create probe
    1.41   }
    1.42 - VMSSemReq;
    1.43 +VMSSemReq;
    1.44 +
    1.45 +//These are for Master to Master requests
    1.46 +// They get re-cast to the appropriate sub-type of request
    1.47 +enum InterMasterReqstType    //For Master->Master
    1.48 + {
    1.49 +   destVMSCore = 1,          //avoid starting enums at 0, for debug reasons
    1.50 +   destPlugin
    1.51 + };
    1.52 +
    1.53 +struct _InterMasterReqst //Doing a trick to save space & time -- allocate
    1.54 + {  // space for a sub-type then cast first as InterMaster then as sub-type
    1.55 +   enum InterMasterReqstType  reqType;
    1.56 +   InterMasterReqst *nextReqst;
    1.57 + };
    1.58 +//InterMasterReqst  (defined above in typedef block)
    1.59 +
    1.60 +
    1.61 +//These are a sub-type of InterMaster requests.  The inter-master req gets
    1.62 +// re-cast to be of this type, after checking
    1.63 +//This ones for requests between internals of VMS-core.. such as malloc
    1.64 +enum InterVMSCoreReqType   
    1.65 + {
    1.66 +   transfer_free_ptr = 1     //avoid starting enums at 0, for debug reasons
    1.67 + };
    1.68 +
    1.69 +typedef struct  //Doing a trick to save space & time -- allocate space
    1.70 + {              // for this, cast first as InterMaster then as this
    1.71 +   enum InterMasterReqstType  reqType;  //duplicate InterMasterReqst at top
    1.72 +   InterMasterReqst *nextReqst;
    1.73 +   
    1.74 +   enum InterVMSCoreReqType  secondReqType;
    1.75 +   void                     *freePtr;  //pile up fields, add as needed
    1.76 + }
    1.77 +InterVMSCoreReqst;
    1.78 +
    1.79 +
    1.80 +//This is for requests between plugins on different cores
    1.81 +// Here, after casting, the pluginReq is extracted and handed to plugin
    1.82 +typedef struct  //Doing a trick to save space & time -- allocate space
    1.83 + {              // for this, cast first as InterMaster then as this
    1.84 +   enum InterMasterReqstType  reqType;  //copy InterMasterReqst at top
    1.85 +   InterMasterReqst          *nextReqst;
    1.86 +   
    1.87 +   void                      *pluginReq; //plugin will cast to approp type
    1.88 + }
    1.89 +InterPluginReqst;
    1.90  
    1.91  
    1.92  //====================  Core data structures  ===================
    1.93 @@ -209,9 +261,8 @@
    1.94  //VirtProcr
    1.95  
    1.96  
    1.97 -/*WARNING: re-arranging this data structure could cause VP-switching
    1.98 - *         assembly code to fail -- hard-codes offsets of fields
    1.99 - *         (because -O3 messes with things otherwise)
   1.100 +/*Master Env is the only global variable -- has entry points for any other
   1.101 + * data needed.  
   1.102   */
   1.103  typedef struct
   1.104   {
   1.105 @@ -368,6 +419,14 @@
   1.106  inline void
   1.107  VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
   1.108  
   1.109 +
   1.110 +void inline
   1.111 +VMS__send_inter_plugin_req( void *reqData, int32 targetMaster, 
   1.112 +                                            VirtProcr *requestingMaster );
   1.113 +void inline
   1.114 +VMS__send_inter_VMSCore_req( InterVMSCoreReqst *reqData, int32 targetMaster,
   1.115 +                                           VirtProcr *requestingMaster );
   1.116 +
   1.117  VMSReqst *
   1.118  VMS__take_next_request_out_of( VirtProcr *procrWithReq );
   1.119