|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Legacy page-based shared-memory allocator (predecessor of MemoryManager). More...
#include <MemoryManager.h>
Public Member Functions | |
| MemoryManagerX () | |
| ~MemoryManagerX () | |
| bool | connect (uint16 sysID) |
| bool | create (uint16 sysID, uint32 staticPageTableSize=100, uint32 slotCount=360, uint32 slotDuration=60000000, uint32 pagesPerSlot=10, bool force=false) |
| bool | insertMemoryBlock (const char *data, uint32 size, uint64 eol, uint64 &id) |
| bool | overwriteMemoryBlock (uint64 id, const char *data, uint32 size, uint64 eol) |
| char * | getAndLockMemoryBlock (uint64 id, uint32 &size, uint64 &eol) |
| char * | getLockedMemoryBlock (MemoryPage *page, uint64 id, uint32 &size, uint64 &eol) |
| bool | unlockMemoryBlock (uint64 id) |
| char * | getCopyMemoryBlock (uint64 id, uint32 &size, uint64 &eol) |
| char * | getSystemBlock (uint32 pageID, uint32 &size) |
| char * | getAndLockSystemBlock (uint32 pageID, uint32 &size) |
| char * | getLockedSystemBlock (uint32 pageID, uint32 &size) |
| char * | getLockedSystemBlock (MemoryPage *page, uint32 &size) |
| bool | unlockSystemBlock (uint32 pageID) |
| char * | createAndLockNewSystemPage (uint32 size, uint32 &id) |
| char * | resizeSystemPage (uint32 pageID, uint32 size) |
Static Public Member Functions | |
| static char * | GetAndLockSystemBlock (uint32 pageID, uint32 &size) |
| Map and lock the system page pageID; pair with UnlockSystemBlock(). | |
| static bool | UnlockSystemBlock (uint32 pageID) |
| Release the lock taken by GetAndLockSystemBlock(). | |
| static char * | CreateAndLockNewSystemPage (uint32 size, uint32 &id) |
| static char * | ResizeSystemPage (uint32 pageID, uint32 newSize) |
| static bool | GetMemoryUsage (uint32 &total, uint32 &usage, uint32 &sysTotal, uint32 &sysUsage, uint32 &staticTotal, uint32 &staticUsage, uint32 &dynamicTotal, uint32 &dynamicUsage) |
| static bool | DestroySystemPage (uint32 pageID) |
| static bool | InsertMemoryBlock (const char *data, uint32 size, uint64 eol, uint64 &id) |
| Copy data into a new shared block. | |
| static bool | OverwriteMemoryBlock (uint64 id, const char *data, uint32 size, uint64 eol) |
| Replace the contents of an existing block. | |
| static char * | GetAndLockMemoryBlock (uint64 id, uint32 &size, uint64 &eol) |
| Lock a block and return a pointer into shared memory; pair with UnlockMemoryBlock(). | |
| static bool | UnlockMemoryBlock (uint64 id) |
| Release the lock taken by GetAndLockMemoryBlock(). | |
| static char * | GetCopyMemoryBlock (uint64 id, uint32 &size, uint64 &eol) |
| Return a heap copy of a block; caller owns and must free it. | |
| static bool | UnitTest () |
| Self-test of the legacy page allocator. | |
Static Public Attributes | |
| static MemoryManagerX * | Singleton |
| Per-process singleton instance. | |
Friends | |
| THREAD_RET THREAD_FUNCTION_CALL | MemoryManagement (THREAD_ARG arg) |
| Background maintenance thread entry point for MemoryManager / MemoryManagerX. | |
Legacy page-based shared-memory allocator (predecessor of MemoryManager).
Manages a single "PageMaster" segment divided into system, static and dynamic (EOL) pages, with block-level allocation inside pages and a time-wheel for expiry. Retained for compatibility and its unit tests; new code should use MemoryManager/TemporalMemory. Blocks are addressed by 64-bit ids (see MP_CalcID). get-and-lock calls must be paired with the corresponding unlock; returned pointers point directly into shared memory and are only valid while locked. getCopy* variants return heap copies owned by the caller.
Definition at line 736 of file MemoryManager.h.
| cmlabs::MemoryManagerX::MemoryManagerX | ( | ) |
| cmlabs::MemoryManagerX::~MemoryManagerX | ( | ) |
| bool cmlabs::MemoryManagerX::connect | ( | uint16 | sysID | ) |
| bool cmlabs::MemoryManagerX::create | ( | uint16 | sysID, |
| uint32 | staticPageTableSize = 100, | ||
| uint32 | slotCount = 360, | ||
| uint32 | slotDuration = 60000000, | ||
| uint32 | pagesPerSlot = 10, | ||
| bool | force = false ) |
|
static |
| char * cmlabs::MemoryManagerX::createAndLockNewSystemPage | ( | uint32 | size, |
| uint32 & | id ) |
|
static |
|
static |
Lock a block and return a pointer into shared memory; pair with UnlockMemoryBlock().
| char * cmlabs::MemoryManagerX::getAndLockMemoryBlock | ( | uint64 | id, |
| uint32 & | size, | ||
| uint64 & | eol ) |
|
static |
Map and lock the system page pageID; pair with UnlockSystemBlock().
| pageID | Reserved system page id. |
| size | Receives block size. |
| char * cmlabs::MemoryManagerX::getAndLockSystemBlock | ( | uint32 | pageID, |
| uint32 & | size ) |
|
static |
Return a heap copy of a block; caller owns and must free it.
| char * cmlabs::MemoryManagerX::getCopyMemoryBlock | ( | uint64 | id, |
| uint32 & | size, | ||
| uint64 & | eol ) |
| char * cmlabs::MemoryManagerX::getLockedMemoryBlock | ( | MemoryPage * | page, |
| uint64 | id, | ||
| uint32 & | size, | ||
| uint64 & | eol ) |
| char * cmlabs::MemoryManagerX::getLockedSystemBlock | ( | MemoryPage * | page, |
| uint32 & | size ) |
| char * cmlabs::MemoryManagerX::getLockedSystemBlock | ( | uint32 | pageID, |
| uint32 & | size ) |
|
static |
| char * cmlabs::MemoryManagerX::getSystemBlock | ( | uint32 | pageID, |
| uint32 & | size ) |
|
static |
Copy data into a new shared block.
| data | Source bytes (caller keeps ownership). |
| size | Byte count. |
| eol | Absolute expiry time (0 = static). |
| id | Receives the global block id. |
| bool cmlabs::MemoryManagerX::insertMemoryBlock | ( | const char * | data, |
| uint32 | size, | ||
| uint64 | eol, | ||
| uint64 & | id ) |
|
static |
Replace the contents of an existing block.
| bool cmlabs::MemoryManagerX::overwriteMemoryBlock | ( | uint64 | id, |
| const char * | data, | ||
| uint32 | size, | ||
| uint64 | eol ) |
|
static |
| char * cmlabs::MemoryManagerX::resizeSystemPage | ( | uint32 | pageID, |
| uint32 | size ) |
|
static |
Self-test of the legacy page allocator.
References THREAD_ARG, THREAD_FUNCTION_CALL, and THREAD_RET.
|
static |
Release the lock taken by GetAndLockMemoryBlock().
| bool cmlabs::MemoryManagerX::unlockMemoryBlock | ( | uint64 | id | ) |
|
static |
Release the lock taken by GetAndLockSystemBlock().
| bool cmlabs::MemoryManagerX::unlockSystemBlock | ( | uint32 | pageID | ) |
|
friend |
Background maintenance thread entry point for MemoryManager / MemoryManagerX.
| arg | The manager instance (cast internally). |
Definition at line 743 of file MemoryManager.cpp.
|
static |
Per-process singleton instance.
Definition at line 738 of file MemoryManager.h.