CMSDK  2.0.1
MemoryManager.h
1 #if !defined(_MEMORYMANAGER_H_)
2 #define _MEMORYMANAGER_H_
3 
4 #include "MemoryController.h"
5 #include "Utils.h"
6 #include "ThreadManager.h"
7 #include "DataMessage.h"
8 
9 namespace cmlabs {
10 
11 #define PSYCLONE_STATUS_NONE 0
12 #define PSYCLONE_STATUS_ENDED 1
13 #define PSYCLONE_STATUS_INIT 2
14 #define PSYCLONE_STATUS_READY 3
15 
16 #define DRAFTMSGSIZE 4096
17 
19  uint32 size;
20  uint32 cid;
21  uint32 count;
22  // PsycloneIndexEntries
23 };
24 
26  uint16 port;
27  uint8 status;
28  uint64 heartbeat;
29  uint64 instanceID;
30 };
31 
32 #define PSYCLONE_INDEX_MAXCOUNT 128
33 #define PSYCLONE_INDEX_SIZE (sizeof(PsycloneIndexStruct) + (PSYCLONE_INDEX_MAXCOUNT * sizeof(PsycloneIndexEntry)))
34 
36 public:
37  static bool GetStatus(uint16 port, uint8& status, uint64& heartbeat);
38 
39  PsycloneIndex();
40  ~PsycloneIndex();
41  bool init(uint16 port, uint64 instID);
42  bool setStatus(uint8 status);
43 private:
44  PsycloneIndexStruct* index;
45  PsycloneIndexEntry* entry;
46 };
47 
48 struct PerfStats {
49  uint32 compID;
50  uint16 spaceID;
51  uint16 nodeID;
52  uint32 osID;
53  uint8 type;
54  uint8 status; // Component status (idle, running, etc.)
55 
56  uint64 currentCPUTicks;
57 
58  uint64 currentMemoryBytes;
59 
60  uint64 totalInputBytes;
61  uint64 totalInputCount;
62  uint64 totalOutputBytes;
63  uint64 totalOutputCount;
64 
65  uint64 runCount;
66  uint64 totalQueueBytes;
67  uint32 totalQueueCount;
68 
69  uint64 firstRunStartTime;
70  uint64 currentRunStartTime;
71  uint64 totalCycleCount;
72  uint64 totalRunCount;
73  uint32 migrationCount;
74 };
75 
77  uint64 time;
78  uint32 periodsMS[3];
79 
80  PerfStats lastStats;
81 
82  double percentOfSystemCPU[3];
83  double percentOfOSCPU[3];
84  double localSystemCPUUsage[3];
85  double localSystemMemoryUsage[3];
86  double computerCPUUsage[3];
87  double computerMemoryUsage[3];
88 
89  uint64 maxMemoryBytes;
90  double memoryBytesAverage[3];
91 
92  double dataInputBytesPerSec[3];
93  double dataInputCountPerSec[3];
94  double dataOutputBytesPerSec[3];
95  double dataOutputCountPerSec[3];
96 
97  double dataQueueBytesAverage[3];
98  uint64 dataQueueCountAverage[3];
99 
100  double cycleCountPerSec[3];
101 
102  std::string toXML() {
103  return utils::StringFormat("<performance time=\"%llu\" ms1=\"%u\" ms2=\"%u\" ms3=\"%u\" maxmemory=\"%llu\" "
104  "percentofsystemcpu1=\"%f\" percentofsystemcpu2=\"%f\" percentofsystemcpu3=\"%f\" "
105  "percentofoscpu1=\"%f\" percentofoscpu2=\"%f\" percentofoscpu3=\"%f\" "
106  "memorybytesaverage1=\"%f\" memorybytesaverage2=\"%f\" memorybytesaverage3=\"%f\" "
107  "datainputbytespersec1=\"%f\" datainputbytespersec2=\"%f\" datainputbytespersec3=\"%f\" "
108  "datainputcountpersec1=\"%f\" datainputcountpersec2=\"%f\" datainputcountpersec3=\"%f\" "
109  "dataoutputbytespersec1=\"%f\" dataoutputbytespersec2=\"%f\" dataoutputbytespersec3=\"%f\" "
110  "dataoutputcountpersec1=\"%f\" dataoutputcountpersec2=\"%f\" dataoutputcountpersec3=\"%f\" "
111  "dataqueuebytesaverage1=\"%f\" dataqueuebytesaverage2=\"%f\" dataqueuebytesaverage3=\"%f\" "
112  "dataqueuecountaverage1=\"%f\" dataqueuecountaverage2=\"%f\" dataqueuecountaverage3=\"%f\" "
113  "cyclecountpersec1=\"%f\" cyclecountpersec2=\"%f\" cyclecountpersec3=\"%f\" "
114  "localsystemcpuusage1=\"%f\" localsystemcpuusage2=\"%f\" localsystemcpuusage3=\"%f\" "
115  "localsystemmemoryusage1=\"%f\" localsystemmemoryusage2=\"%f\" localsystemmemoryusage3=\"%f\" "
116  "computercpuusage1=\"%f\" computercpuusage2=\"%f\" computercpuusage3=\"%f\" "
117  "computermemoryusage1=\"%f\" computermemoryusage2=\"%f\" computermemoryusage3=\"%f\" "
118  "/>\n",
119  time, periodsMS[0], periodsMS[1], periodsMS[2], maxMemoryBytes,
120  percentOfSystemCPU[0], percentOfSystemCPU[1], percentOfSystemCPU[2],
121  percentOfOSCPU[0], percentOfOSCPU[1], percentOfOSCPU[2],
122  memoryBytesAverage[0], memoryBytesAverage[1], memoryBytesAverage[2],
123  dataInputBytesPerSec[0], dataInputBytesPerSec[1], dataInputBytesPerSec[2],
124  dataInputCountPerSec[0], dataInputCountPerSec[1], dataInputCountPerSec[2],
125  dataOutputBytesPerSec[0], dataOutputBytesPerSec[1], dataOutputBytesPerSec[2],
126  dataOutputCountPerSec[0], dataOutputCountPerSec[1], dataOutputCountPerSec[2],
127  dataQueueBytesAverage[0], dataQueueBytesAverage[1], dataQueueBytesAverage[2],
128  dataQueueCountAverage[0], dataQueueCountAverage[1], dataQueueCountAverage[2],
129  cycleCountPerSec[0], cycleCountPerSec[1], cycleCountPerSec[2],
130  localSystemCPUUsage[0], localSystemCPUUsage[1], localSystemCPUUsage[2],
131  localSystemMemoryUsage[0], localSystemMemoryUsage[1], localSystemMemoryUsage[2],
132  computerCPUUsage[0], computerCPUUsage[1], computerCPUUsage[2],
133  computerMemoryUsage[0], computerMemoryUsage[1], computerMemoryUsage[2]
134  );
135  }
136 };
137 
138 
140  uint64 size;
141  uint32 cid;
142  uint16 nodeID;
143  uint16 status; // 0-10, where 10 means ready
144  uint64 createdTime; // time of creation
145  // uint64 timesync; // time sync
146  uint64 currentTMC;
147  int64 localSyncAdjustment;
148  uint64 memAlloc; //
149  uint64 memUsage; //
150  uint64 currentCPUTicks; //
151  uint32 componentCount; //
152  uint32 throughputCount; //
153  uint64 throughputSize; //
154  uint32 dynamicShmemSerial;
155  uint32 processShmemSerial;
156  uint32 componentShmemSerial;
157  uint32 datamapsShmemSerial;
158  uint32 dynamicShmemLocks;
159  uint32 processShmemLocks;
160  uint32 componentShmemLocks;
161  // uint32 datamapsShmemLocks; // nothing ever locks in here beyond the simple mutex
162  uint64 dynamicShmemSize;
163  uint64 processShmemSize;
164  uint64 componentShmemSize;
165  uint64 datamapsShmemSize;
166 };
167 
168 class MemoryManager;
170  friend class MemoryManager;
171 public:
172  MasterMemory();
173  ~MasterMemory();
174  bool create(uint16 port);
175  bool open(uint16 port);
176 
177  uint16 getNodeID();
178  bool setNodeID(uint16 id);
179  uint64 getCreatedTime();
180 
181  uint32 getDynamicShmemSerial();
182  uint32 getProcessShmemSerial();
183  uint32 getComponentShmemSerial();
184  uint32 getDataMapsShmemSerial();
185  uint32 incrementDynamicShmemSerial();
186  uint32 incrementProcessShmemSerial();
187  uint32 incrementComponentShmemSerial();
188  uint32 incrementDataMapsShmemSerial();
189 
190  uint64 getDynamicShmemSize();
191  uint64 getProcessShmemSize();
192  uint64 getComponentShmemSize();
193  uint64 getDataMapsShmemSize();
194  bool setDynamicShmemSize(uint64 size);
195  bool setProcessShmemSize(uint64 size);
196  bool setComponentShmemSize(uint64 size);
197  bool setDataMapsShmemSize(uint64 size);
198 
199  bool setID(uint16 id);
200  uint16 getID();
201 
202  uint16 port;
203 
204 private:
205  utils::Mutex* mutex;
206  MemoryMasterStruct* master;
207 };
208 
209 class TemporalMemory;
210 class ProcessMemory;
211 class ComponentMemory;
212 class DataMapsMemory;
213 
215 public:
216  static MemoryManager* Singleton;
217 
218  //static bool GetMemoryUsage(uint32& total, uint32& usage, uint32& sysTotal, uint32& sysUsage, uint32& staticTotal, uint32& staticUsage, uint32& dynamicTotal, uint32& dynamicUsage);
219  //static bool InsertMemoryBlock(const char* data, uint32 size, uint64 eol, uint64& id);
220  //static bool OverwriteMemoryBlock(uint64 id, const char* data, uint32 size, uint64 eol);
221  //static char* GetAndLockMemoryBlock(uint64 id, uint32& size, uint64& eol);
222  //static bool UnlockMemoryBlock(uint64 id);
223  //static char* GetCopyMemoryBlock(uint64 id, uint32& size, uint64& eol);
224 
225  static bool UnitTest();
226  static bool ShmUnitTest();
227 
228  friend THREAD_RET THREAD_FUNCTION_CALL MemoryManagement(THREAD_ARG arg);
229 
230  MemoryManager();
231  ~MemoryManager();
232 
233  bool getMemoryUsage(uint64& sysAlloc, uint64& sysUsage, uint64& dataAlloc, uint64& dataUsage);
234 
235  uint8 getNodeStatus(uint64& lastseen, uint64& createdTime);
236 
237  // Connect to existing PageMaster in shared memory
238  bool connect(uint16 sysID, bool isMaster);
239 
240  // Create a new PageMaster in shared memory
241  bool create(uint16 sysID, uint32 slotCount = 100000, uint16 binCount = 2, uint32 minBlockSize = 1024, uint32 maxBlockSize = 64*1024, uint64 initSize = 50000000L, uint64 maxSize = 1000000000L, bool force = false);
242  //uint16 sysID, uint32 slotCount = 100, uint32 slotDuration = 100000, uint64 initSize = 10000000, uint64 maxSize = 100000000, uint32 growSteps = 8, bool force = false);
243 
244  // Insert new block of memory and return full id
245  bool insertMessage(DataMessage* msg, uint64& id);
246  // Get copy of block of memory
247  DataMessage* getCopyOfMessage(uint64 id);
248 
249  std::string typeToText(PsyType type);
250  std::string subTypeToText(uint16 subtype);
251  std::string contextToText(PsyContext context);
252  std::string subContextToText(uint16 subcontext);
253  std::string getComponentName(uint32 compID);
254 
255  uint16 getNodeID();
256  bool setNodeID(uint16 id);
257 
258  DataMessage* retrieveAllSystemIDs();
259 
260 
261  bool getTimeSyncData(uint64& tmc, int64& adjust);
262  bool setTimeSyncData(uint64 tmc, int64 adjust);
263 
264  TemporalMemory* temporalMemory; // Shared memory
265  ProcessMemory* processMemory; // Shared memory
266  ComponentMemory* componentMemory; // Shared memory
267  DataMapsMemory* dataMapsMemory; // Shared memory
268 
269 private:
270  // Continuous management of eol pages
271  uint32 runManager();
272 
273  // Resize the EOL Page
274  bool resizeEOLPage(uint32 slotCount, uint32 pagesPerSlot, uint32 slotDuration);
275 
276  PsycloneIndex* psycloneIndex; // Shared memory
277  MasterMemory* masterMemory; // Shared memory
278 
279 
280  bool shouldContinue;
281  bool isRunning;
282  bool isLocalMaster;
283  uint32 managementThreadID;
284  uint16 thisInstance;
285 };
286 
287 
288 
289 
290 
291 
292 
293 
294 
295 
296 
297 
298 
299 
300 #define MAXREGISTERCOUNT 64
301 
302 struct CMRegister {
303  uint16 size; // size of memory allocation
304  uint16 count; // number of entries
305  // MAXREGISTERCOUNT x uint16 sysIDs
306 };
307 
308 THREAD_RET THREAD_FUNCTION_CALL MemoryManagement(THREAD_ARG arg);
309 
310 #define NODE_PROCESS_ID 1
311 #define MAXINSTANCES 256
312 
313 
314 struct MemoryID {
315  uint32 pageID; // contains [8] PageSerial [24] PageLoc
316  uint16 blockID; // index containing block offset
317  uint16 sysID; // global node id
318 };
319 
320 struct MemoryBlock {
321  uint32 size;
322 // char* data;
323 };
324 
326  uint32 size; // total size of pool structure in bytes
327  // uint32 size, uint64 time, uint32 pageID
328 };
329 
331  uint32 dataSize; // page data size
332  uint64 time; // time of entry into pool
333  uint32 pageID; // ID of page
334 };
335 
336 struct EOLHeader {
337  uint32 slotCount;
338  uint32 pagesPerSlot;
339  uint32 startSlot;
340  uint64 startTime;
341  uint32 slotDuration;
342  // slot0: page0,eol0 , page1,eol1 ..., pageN,eolN
343  // slot1: page0,eol0 , page1,eol1 ..., pageN,eolN
344 };
345 
346 struct EOLEntry {
347  uint32 pageID;
348  uint64 eol;
349 };
350 
351 #define MP_GetBlockIndexStartLoc(p) ((char*)p + sizeof(MemoryPage))
352 #define MP_GetBlockDataStartLoc(p) (MP_GetBlockIndexStartLoc(p) + (p->blockTableSize*sizeof(uint32)) )
353 //#define MP_GetBlockOffsetLoc(p,n) (uint32*)(MP_GetBlockIndexStartLoc(p) + (n * sizeof(uint32)))
354 //#define MP_GetBlockOffset(p,n) (*(MP_GetBlockOffsetLoc(p,n)))
355 //#define MP_GetBlockLoc(p,n) MP_GetBlockDataStartLoc(p) + MP_GetBlockOffset(p,n)
356 
357 struct MemoryPage {
358  uint32 size; // total size of page in bytes
359  uint64 eol; // current number of blocks in use -> first free location
360  uint32 dataSize; // total size of data space in bytes
361  uint32 dataUsage; // current usage of page in bytes
362  uint16 count; // current number of blocks in use -> first free location
363  uint16 blockTableSize; // maximum entries in index table
364 // uint16 blockTable[1024]; // index table containing block offsets
365 // char* data; // MemoryBlock0, MemoryBlock1, ..., MemoryBlockN
366 };
367 
369  uint8 pageSerial; // running serial number for this page location (0-255)
370  uint8 cacheSerial; // running serial number for this page cache (0-255)
371  uint32 pageSize;
372  uint32 pageID;
373  uint64 lockID;
374  uint64 lockTime;
375  uint16 lockCount;
376 };
377 
379  uint32 size; // total size of structure in bytes
380  uint32 count; // total number of cache entries allocated
381  // MemoryPageCacheEntries...
382 };
383 
385  uint8 pageSerial; // running serial number for this page location (0-255)
386  uint8 cacheSerial; // running serial number for this page cache (0-255)
387  uint32 pageSize;
388  uint32 pageID;
389  MemoryPage* page;
390 };
391 
392 #define MP_SYSMEMID MP_CalcID(0, 0, pageMaster->nodeID)
393 #define MP_CalcID(pid,bid,nid) ((uint64)pid | (((uint64)bid) << 32) | (((uint64)nid) << 48))
394 #define MP_SetBlockID(id,var) var |= (((uint64)id) << 32)
395 #define MP_SetNodeID(id,var) var |= (((uint64)id) << 48)
396 #define MP_SetPageID(id,var) var |= ((uint64)id)
397 #define MP_GetBlockID(id) (*(uint16*)((char*)&id + sizeof(uint32)))
398 #define MP_GetNodeID(id) (*(uint16*)((char*)&id + sizeof(uint32) + sizeof(uint16)))
399 #define MP_GetPageID(id) (*(uint32*)(char*)&id)
400 #define MP_GetBitFieldLoc(m) ((char*)m + sizeof(MemoryPageMaster))
401 #define MP_GetPageTableLoc(m) (MP_GetBitFieldLoc(m) + m->bitFieldSize )
402 #define MP_GetPageEntryLoc(m,pid) (MP_GetPageTableLoc(m) + (pid * sizeof(MemoryPageEntry)) )
403 #define MP_GetPageLoc(m,pid) ((MemoryPageEntry*)MP_GetPageEntryLoc(m,pid))->page
404 
405 #define MP_SYSTEMPAGE 0
406 #define MP_STATICPAGE 1
407 #define MP_DYNAMICPAGE 2
408 #define MP_GetPageType(id,eol) ( ((id < RESERVEDPAGECOUNT) ? MP_SYSTEMPAGE : (eol > 0 ? MP_DYNAMICPAGE : MP_STATICPAGE) ) )
409 
411  uint32 size; // total size of PageMaster in bytes
412  uint16 sysID; // global node id
413  uint16 status; // 0-10, where 10 means ready
414  uint64 createdTime; // time of creation
415  uint8 instance; // Instance number on each computer
416  uint64 timesync; // time sync
417  uint32 pagesSize; // total size of all pages in bytes {system, static, EOL}
418  uint32 dataSize[3]; // total size of all pages data spaces in bytes {system, static, EOL}
419  uint32 dataUsage[3]; // current usage of all pages in bytes {system, static, EOL}
420  uint32 count[3]; // current number of pages in use, for info only {system, static, EOL}
421  uint32 lastCreatedStaticPage; // id of last created static page
422  uint32 bitFieldSize; // number of bytes in the bitfield
423  uint32 pageTableSize; // maximum entries in page table and number of bits in bit field
424  // char* pageBitfield; // which pages are in use -> 111010001110101010....011010
425  // MemoryPageEntry* pageTable; // {ID24 offset -> address of MemoryPageEntry}
426 };
427 
428 // SystemBlock for system data
429 
430 // structure for managing ttl pages
431 
433 public:
434  static MemoryManagerX* Singleton;
435 
436  static char* GetAndLockSystemBlock(uint32 pageID, uint32& size);
437  static bool UnlockSystemBlock(uint32 pageID);
438  // Creates a new System Page with the next id
439  static char* CreateAndLockNewSystemPage(uint32 size, uint32& id);
440  // Resize an existing System Page
441  static char* ResizeSystemPage(uint32 pageID, uint32 newSize);
442  static bool GetMemoryUsage(uint32& total, uint32& usage, uint32& sysTotal, uint32& sysUsage, uint32& staticTotal, uint32& staticUsage, uint32& dynamicTotal, uint32& dynamicUsage);
443  // Destroys an exising System Page by id
444  static bool DestroySystemPage(uint32 pageID);
445 
446  static bool InsertMemoryBlock(const char* data, uint32 size, uint64 eol, uint64& id);
447  static bool OverwriteMemoryBlock(uint64 id, const char* data, uint32 size, uint64 eol);
448  static char* GetAndLockMemoryBlock(uint64 id, uint32& size, uint64& eol);
449  static bool UnlockMemoryBlock(uint64 id);
450  static char* GetCopyMemoryBlock(uint64 id, uint32& size, uint64& eol);
451 
452  static bool UnitTest();
453 
454  friend THREAD_RET THREAD_FUNCTION_CALL MemoryManagement(THREAD_ARG arg);
455 
456  MemoryManagerX();
457  ~MemoryManagerX();
458 
459  // Connect to existing PageMaster in shared memory
460  bool connect(uint16 sysID);
461 
462  // Create a new PageMaster in shared memory
463  bool create(uint16 sysID, uint32 staticPageTableSize = 100, uint32 slotCount = 360, uint32 slotDuration = 60000000, uint32 pagesPerSlot = 10, bool force = false);
464 
465  // Either look up location of or create a new PageMaster in shared memory
466  // bool init(uint16 nodeID, uint32 pageTableSize, uint32 slotCount = 600, uint32 slotDuration = 1000000, uint32 bufferSlots = 10, uint32 pagesPerSlot = 1024);
467 
468  // Insert new block of memory and return full id
469  bool insertMemoryBlock(const char* data, uint32 size, uint64 eol, uint64& id);
470 
471  // Overwrite existing block of memory
472  bool overwriteMemoryBlock(uint64 id, const char* data, uint32 size, uint64 eol);
473 
474  char* getAndLockMemoryBlock(uint64 id, uint32& size, uint64& eol);
475  char* getLockedMemoryBlock(MemoryPage* page, uint64 id, uint32& size, uint64& eol);
476  bool unlockMemoryBlock(uint64 id);
477  char* getCopyMemoryBlock(uint64 id, uint32& size, uint64& eol);
478 
479  // Return a system memory block
480  char* getSystemBlock(uint32 pageID, uint32& size);
481 
482  // Return a system memory block and lock it
483  char* getAndLockSystemBlock(uint32 pageID, uint32& size);
484  char* getLockedSystemBlock(uint32 pageID, uint32& size);
485  char* getLockedSystemBlock(MemoryPage* page, uint32& size);
486 
487  // Unlock System Block
488  bool unlockSystemBlock(uint32 pageID);
489 
490  // Creates a new System Page with the next id
491  char* createAndLockNewSystemPage(uint32 size, uint32& id);
492  // Resize an existing System Page
493  char* resizeSystemPage(uint32 pageID, uint32 size);
494 
495 private:
496  // Create new MemoryPage
497  MemoryPage* createPage(uint32 size, uint16 tableSize, uint64 eol, uint32& pageID); // if either parameter is 0, the default values will be used
498 
499  // Insert new block of memory into a specific page and return full id
500  bool insertMemoryBlockIntoPage(uint32 pageID, const char* data, uint32 size, uint64 eol, uint64& id);
501 
502  // Create a new Page Mutex
503  // Mutex createPageMutex(uint32 id);
504  // Get an existing Page Mutex
505  // bool getPageMutex(uint32 id, NMutex &mutex);
506  // Destroy a Page Mutex
507  // bool destroyPageMutex(uint32 id);
508 
509 // utils::Semaphore* getPageSemaphore(uint32 pageID);
510 // utils::Mutex* getPageMutex(uint32 pageID);
511 
512  bool lockPage(uint32 pageID);
513  bool unlockPage(uint32 pageID);
514 // bool lockPage(MemoryPage* page);
515 // bool unlockPage(MemoryPage* page);
516  bool lockPage(MemoryPageEntry* entry);
517  bool unlockPage(MemoryPageEntry* entry);
518 
519  // Find an available page appropriate for the block size and ttl
520  MemoryPage* findPageForBlock(uint32 size, uint64 eol, uint32& id);
521 
522  // Free up a page and put it into the pool
523  bool freePageIntoPool(uint32 pageID);
524 
525  // Remove page from stats, but do not delete
526  bool removePageFromStats(uint32 pageID, uint32& dataSize);
527 
528  // Insert a page into the idle pool
529  bool insertPageIntoPool(uint32 pageID, uint32 dataSize);
530 
531  // Get page with required size from the idle pool
532  bool getPageFromPool(uint32 size, uint32& pageID);
533 
534  // Destroy all Memory Pages
535  bool destroyAllPages();
536 
537  // Destroy a Memory Page
538  bool destroyPage(uint32 pageID, bool updateStats = true);
539 
540  // Continuous management of eol pages
541  uint32 runManager();
542 
543  // Return string representing the bitfield
544  char* getBitFieldAsString(uint32& size);
545  // Print string representing the bitfield
546  bool printBitFieldAsString(char* title);
547 
548  // Get the percentage in use of a page
549  bool getPageUsage(uint32 pageID, double& val);
550  // Get the percentage in use of a page
551  double getPageUsage(uint32 pageID);
552  // Get the number of bytes free of a page
553  bool getPageFree(uint32 pageID, uint32& bytes);
554  // Get the total size in bytes a page
555  bool getPageSize(uint32 pageID, uint32& bytes);
556 
557  // Creates a System Page
558  char* createSystemPage(uint32 id, uint32 size, uint64& memID);
559 
560  // Create the Manager System Pages
561  bool createSystemPages();
562 
563  // Initialise the System Page
564  bool initSystemPage(char* data, uint32 size);
565 
566  // Initialise the Page Pool
567  bool initPagePool(char* data, uint32 size);
568 
569  // Resize the EOL Page
570  bool resizeEOLPage(uint32 slotCount, uint32 pagesPerSlot, uint32 slotDuration, uint32 bufferSlots);
571 
572  // Insert page into EOL Structure
573  bool insertPageIntoEOL(uint32 pageID, uint64 eol, uint64& slotEOL);
574 
575  // Initialise the Queue Page
576  bool initQueuePage(char* data, uint32 size);
577 
578  // Calculate the new page size based on incoming block size
579  static uint16 CalcBlockTableSize(uint32 size);
580 
581  MemoryPage* getCachedPage(uint32 pageID);
582  MemoryPage* getCachedPage(MemoryPageEntry *entry);
583  bool updateCachedPage(MemoryPageEntry *entry, MemoryPage *page);
584 
585  MemoryPageMaster* pageMaster; // Shared memory location of PageMaster, looked up or created
586  utils::Mutex *pageMasterMutex; // Handle to global mutex for PageMaster access
587  MemoryPageCache* pageCache; // Non-shared memory location of cached page addresses
588  bool shouldContinue;
589  bool isRunning;
590  bool isMaster;
591  uint32 managementThreadID;
592  uint16 thisInstance;
593 };
594 
595 } // namespace cmlabs
596 
597 #include "TemporalMemory.h"
598 #include "ComponentMemory.h"
599 #include "DataMapsMemory.h"
600 #include "ProcessMemory.h"
601 
602 #endif //_MEMORYMANAGER_H_
603 
Definition: MemoryManager.h:320
Definition: MemoryManager.h:384
Definition: MemoryManager.h:169
Definition: MemoryManager.h:432
Definition: MemoryController.h:9
Definition: MemoryManager.h:139
Definition: DataMapsMemory.h:190
Definition: Bitmap.h:7
Definition: MemoryManager.h:336
Definition: MemoryManager.h:330
Definition: MemoryManager.h:35
Definition: MemoryManager.h:302
Definition: MemoryManager.h:314
Definition: MemoryManager.h:410
Definition: MemoryManager.h:357
Definition: MemoryManager.h:214
Definition: MemoryManager.h:368
Definition: MemoryManager.h:378
Definition: MemoryManager.h:48
Definition: ProcessMemory.h:125
Definition: TemporalMemory.h:67
Definition: Types.h:207
Definition: MemoryManager.h:18
Definition: ComponentMemory.h:184
Definition: Types.h:80
Definition: MemoryManager.h:325
Definition: MemoryManager.h:25
Definition: Utils.h:276
Definition: MemoryManager.h:346
Definition: MemoryManager.h:76
Definition: DataMessage.h:95