Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.h @ 134:a9b72021f053
Distributed memory management w/o free requests working
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 16 Sep 2011 16:19:24 +0200 |
| parents | dbfc8382d546 |
| children | 0b49fd35afc1 |
comparison
equal
deleted
inserted
replaced
| 58:e26dcf8e33b7 | 59:9f10cf3c4f81 |
|---|---|
| 7 */ | 7 */ |
| 8 #ifndef _VMS_H | 8 #ifndef _VMS_H |
| 9 #define _VMS_H | 9 #define _VMS_H |
| 10 #define _GNU_SOURCE | 10 #define _GNU_SOURCE |
| 11 | 11 |
| 12 #include <pthread.h> | |
| 13 #include <sys/time.h> | |
| 14 | |
| 12 #include "VMS_primitive_data_types.h" | 15 #include "VMS_primitive_data_types.h" |
| 13 #include "Queue_impl/PrivateQueue.h" | 16 #include "Queue_impl/PrivateQueue.h" |
| 14 #include "Histogram/Histogram.h" | 17 #include "Histogram/Histogram.h" |
| 15 #include "DynArray/DynArray.h" | 18 #include "DynArray/DynArray.h" |
| 16 #include "Hash_impl/PrivateHash.h" | 19 #include "Hash_impl/PrivateHash.h" |
| 17 #include "vmalloc.h" | 20 #include "vmalloc.h" |
| 18 | 21 #include "requests.h" |
| 19 #include <pthread.h> | |
| 20 #include <sys/time.h> | |
| 21 | |
| 22 | 22 |
| 23 //=============================== Debug =================================== | 23 //=============================== Debug =================================== |
| 24 // | 24 // |
| 25 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread | 25 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread |
| 26 // It still does co-routines and all the mechanisms are the same, it just | 26 // It still does co-routines and all the mechanisms are the same, it just |
| 87 | 87 |
| 88 // stack size in virtual processors created | 88 // stack size in virtual processors created |
| 89 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ | 89 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ |
| 90 | 90 |
| 91 // memory for VMS__malloc | 91 // memory for VMS__malloc |
| 92 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ | 92 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x4000000 /* 64M */ |
| 93 | 93 |
| 94 #define CACHE_LINE 64 | 94 #define CACHE_LINE 64 |
| 95 #define PAGE_SIZE 4096 | 95 #define PAGE_SIZE 4096 |
| 96 | 96 |
| 97 | 97 |
| 108 | 108 |
| 109 | 109 |
| 110 //=========================================================================== | 110 //=========================================================================== |
| 111 typedef unsigned long long TSCount; | 111 typedef unsigned long long TSCount; |
| 112 | 112 |
| 113 typedef struct _VMSReqst VMSReqst; | |
| 114 typedef struct _InterMasterReqst InterMasterReqst; | |
| 115 typedef struct _IntervalProbe IntervalProbe; | 113 typedef struct _IntervalProbe IntervalProbe; |
| 116 typedef struct _GateStruc GateStruc; | 114 typedef struct _GateStruc GateStruc; |
| 117 | 115 |
| 118 | 116 |
| 119 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx | 117 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx |
| 120 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv | 118 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv |
| 121 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr | |
| 122 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr | |
| 123 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); | 119 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); |
| 124 | 120 |
| 125 | |
| 126 //============= Requests =========== | |
| 127 // | |
| 128 | |
| 129 //VMS Request is the carrier for Slave to Master requests | |
| 130 // it has an embedded sub-type request that is pulled out | |
| 131 // inside the plugin's request handler | |
| 132 enum VMSReqstType //For Slave->Master requests | |
| 133 { | |
| 134 semantic = 1, //avoid starting enums at 0, for debug reasons | |
| 135 createReq, | |
| 136 dissipate, | |
| 137 VMSSemantic //goes with VMSSemReqst below | |
| 138 }; | |
| 139 | |
| 140 struct _VMSReqst | |
| 141 { | |
| 142 enum VMSReqstType reqType;//used for dissipate and in future for IO requests | |
| 143 void *semReqData; | |
| 144 | |
| 145 VMSReqst *nextReqst; | |
| 146 }; | |
| 147 //VMSReqst | |
| 148 | |
| 149 //This is a sub-type of Slave->Master requests. | |
| 150 // It's for Slaves to invoke built-in VMS-core functions that have language-like | |
| 151 // behavior. | |
| 152 enum VMSSemReqstType //These are equivalent to semantic requests, but for | |
| 153 { // VMS's services available directly to app, like OS | |
| 154 createProbe = 1, // and probe services -- like a VMS-wide built-in lang | |
| 155 openFile, | |
| 156 otherIO | |
| 157 }; | |
| 158 | |
| 159 typedef struct | |
| 160 { enum VMSSemReqstType reqType; | |
| 161 VirtProcr *requestingPr; | |
| 162 char *nameStr; //for create probe | |
| 163 } | |
| 164 VMSSemReq; | |
| 165 | |
| 166 //These are for Master to Master requests | |
| 167 // They get re-cast to the appropriate sub-type of request | |
| 168 enum InterMasterReqstType //For Master->Master | |
| 169 { | |
| 170 destVMSCore = 1, //avoid starting enums at 0, for debug reasons | |
| 171 destPlugin | |
| 172 }; | |
| 173 | |
| 174 struct _InterMasterReqst //Doing a trick to save space & time -- allocate | |
| 175 { // space for a sub-type then cast first as InterMaster then as sub-type | |
| 176 enum InterMasterReqstType reqType; | |
| 177 InterMasterReqst *nextReqst; | |
| 178 }; | |
| 179 //InterMasterReqst (defined above in typedef block) | |
| 180 | |
| 181 | |
| 182 //These are a sub-type of InterMaster requests. The inter-master req gets | |
| 183 // re-cast to be of this type, after checking | |
| 184 //This ones for requests between internals of VMS-core.. such as malloc | |
| 185 enum InterVMSCoreReqType | |
| 186 { | |
| 187 transfer_free_ptr = 1 //avoid starting enums at 0, for debug reasons | |
| 188 }; | |
| 189 | |
| 190 //Doing a trick to save space & time -- allocate space | |
| 191 // for this, cast first as InterMaster then as this | |
| 192 typedef struct | |
| 193 { | |
| 194 enum InterMasterReqstType reqType; //duplicate InterMasterReqst at top | |
| 195 InterMasterReqst *nextReqst; | |
| 196 | |
| 197 enum InterVMSCoreReqType secondReqType; | |
| 198 void *freePtr; //pile up fields, add as needed | |
| 199 } InterVMSCoreReqst; | |
| 200 | |
| 201 //This is for requests between plugins on different cores | |
| 202 // Here, after casting, the pluginReq is extracted and handed to plugin | |
| 203 //Doing a trick to save space & time -- allocate space | |
| 204 // for this, cast first as InterMaster then as this | |
| 205 typedef struct | |
| 206 { | |
| 207 enum InterMasterReqstType reqType; //copy InterMasterReqst at top | |
| 208 InterMasterReqst *nextReqst; | |
| 209 | |
| 210 void *pluginReq; //plugin will cast to approp type | |
| 211 } InterPluginReqst; | |
| 212 | 121 |
| 213 //==================== Core data structures =================== | 122 //==================== Core data structures =================== |
| 214 | 123 |
| 215 /*Master Env is the only global variable -- has entry points for any other | 124 /*Master Env is the only global variable -- has entry points for any other |
| 216 * data needed. | 125 * data needed. |
| 309 //===================== Global Vars =================== | 218 //===================== Global Vars =================== |
| 310 | 219 |
| 311 volatile MasterEnv *_VMSMasterEnv; | 220 volatile MasterEnv *_VMSMasterEnv; |
| 312 | 221 |
| 313 | 222 |
| 314 | |
| 315 | |
| 316 //=========================== Function Prototypes ========================= | 223 //=========================== Function Prototypes ========================= |
| 317 | 224 |
| 318 | 225 |
| 319 //========== Setup and shutdown ========== | 226 //========== Setup and shutdown ========== |
| 320 void | 227 void |
| 585 addIntervalToHist( startStamp, endStamp, \ | 492 addIntervalToHist( startStamp, endStamp, \ |
| 586 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); | 493 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); |
| 587 | 494 |
| 588 //===== | 495 //===== |
| 589 | 496 |
| 590 #include "ProcrContext.h" | |
| 591 #include "probes.h" | 497 #include "probes.h" |
| 592 #include "vutilities.h" | 498 #include "vutilities.h" |
| 593 | 499 |
| 594 #endif /* _VMS_H */ | 500 #endif /* _VMS_H */ |
| 595 | 501 |
