CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::MemoryManagerX Class Reference

Legacy page-based shared-memory allocator (predecessor of MemoryManager). More...

#include <MemoryManager.h>

Collaboration diagram for cmlabs::MemoryManagerX:
[legend]

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 MemoryManagerXSingleton
 Per-process singleton instance.

Friends

THREAD_RET THREAD_FUNCTION_CALL MemoryManagement (THREAD_ARG arg)
 Background maintenance thread entry point for MemoryManager / MemoryManagerX.

Detailed Description

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.

Constructor & Destructor Documentation

◆ MemoryManagerX()

cmlabs::MemoryManagerX::MemoryManagerX ( )

◆ ~MemoryManagerX()

cmlabs::MemoryManagerX::~MemoryManagerX ( )

Member Function Documentation

◆ connect()

bool cmlabs::MemoryManagerX::connect ( uint16 sysID)

◆ create()

bool cmlabs::MemoryManagerX::create ( uint16 sysID,
uint32 staticPageTableSize = 100,
uint32 slotCount = 360,
uint32 slotDuration = 60000000,
uint32 pagesPerSlot = 10,
bool force = false )

◆ CreateAndLockNewSystemPage()

char * cmlabs::MemoryManagerX::CreateAndLockNewSystemPage ( uint32 size,
uint32 & id )
static

◆ createAndLockNewSystemPage()

char * cmlabs::MemoryManagerX::createAndLockNewSystemPage ( uint32 size,
uint32 & id )

◆ DestroySystemPage()

bool cmlabs::MemoryManagerX::DestroySystemPage ( uint32 pageID)
static

◆ GetAndLockMemoryBlock()

char * cmlabs::MemoryManagerX::GetAndLockMemoryBlock ( uint64 id,
uint32 & size,
uint64 & eol )
static

Lock a block and return a pointer into shared memory; pair with UnlockMemoryBlock().

Returns
In-segment pointer valid only while locked; NULL if unknown/expired.

◆ getAndLockMemoryBlock()

char * cmlabs::MemoryManagerX::getAndLockMemoryBlock ( uint64 id,
uint32 & size,
uint64 & eol )

◆ GetAndLockSystemBlock()

char * cmlabs::MemoryManagerX::GetAndLockSystemBlock ( uint32 pageID,
uint32 & size )
static

Map and lock the system page pageID; pair with UnlockSystemBlock().

Parameters
pageIDReserved system page id.
sizeReceives block size.
Returns
Pointer into shared memory, valid only while locked; NULL on failure.

◆ getAndLockSystemBlock()

char * cmlabs::MemoryManagerX::getAndLockSystemBlock ( uint32 pageID,
uint32 & size )

◆ GetCopyMemoryBlock()

char * cmlabs::MemoryManagerX::GetCopyMemoryBlock ( uint64 id,
uint32 & size,
uint64 & eol )
static

Return a heap copy of a block; caller owns and must free it.

Returns
Copy or NULL.

◆ getCopyMemoryBlock()

char * cmlabs::MemoryManagerX::getCopyMemoryBlock ( uint64 id,
uint32 & size,
uint64 & eol )

◆ getLockedMemoryBlock()

char * cmlabs::MemoryManagerX::getLockedMemoryBlock ( MemoryPage * page,
uint64 id,
uint32 & size,
uint64 & eol )

◆ getLockedSystemBlock() [1/2]

char * cmlabs::MemoryManagerX::getLockedSystemBlock ( MemoryPage * page,
uint32 & size )

◆ getLockedSystemBlock() [2/2]

char * cmlabs::MemoryManagerX::getLockedSystemBlock ( uint32 pageID,
uint32 & size )

◆ GetMemoryUsage()

bool cmlabs::MemoryManagerX::GetMemoryUsage ( uint32 & total,
uint32 & usage,
uint32 & sysTotal,
uint32 & sysUsage,
uint32 & staticTotal,
uint32 & staticUsage,
uint32 & dynamicTotal,
uint32 & dynamicUsage )
static

◆ getSystemBlock()

char * cmlabs::MemoryManagerX::getSystemBlock ( uint32 pageID,
uint32 & size )

◆ InsertMemoryBlock()

bool cmlabs::MemoryManagerX::InsertMemoryBlock ( const char * data,
uint32 size,
uint64 eol,
uint64 & id )
static

Copy data into a new shared block.

Parameters
dataSource bytes (caller keeps ownership).
sizeByte count.
eolAbsolute expiry time (0 = static).
idReceives the global block id.
Returns
true on success.

◆ insertMemoryBlock()

bool cmlabs::MemoryManagerX::insertMemoryBlock ( const char * data,
uint32 size,
uint64 eol,
uint64 & id )

◆ OverwriteMemoryBlock()

bool cmlabs::MemoryManagerX::OverwriteMemoryBlock ( uint64 id,
const char * data,
uint32 size,
uint64 eol )
static

Replace the contents of an existing block.

Returns
true on success.

◆ overwriteMemoryBlock()

bool cmlabs::MemoryManagerX::overwriteMemoryBlock ( uint64 id,
const char * data,
uint32 size,
uint64 eol )

◆ ResizeSystemPage()

char * cmlabs::MemoryManagerX::ResizeSystemPage ( uint32 pageID,
uint32 newSize )
static

◆ resizeSystemPage()

char * cmlabs::MemoryManagerX::resizeSystemPage ( uint32 pageID,
uint32 size )

◆ UnitTest()

bool cmlabs::MemoryManagerX::UnitTest ( )
static

Self-test of the legacy page allocator.

Returns
true if all checks pass.

References THREAD_ARG, THREAD_FUNCTION_CALL, and THREAD_RET.

◆ UnlockMemoryBlock()

bool cmlabs::MemoryManagerX::UnlockMemoryBlock ( uint64 id)
static

Release the lock taken by GetAndLockMemoryBlock().

Returns
true on success.

◆ unlockMemoryBlock()

bool cmlabs::MemoryManagerX::unlockMemoryBlock ( uint64 id)

◆ UnlockSystemBlock()

bool cmlabs::MemoryManagerX::UnlockSystemBlock ( uint32 pageID)
static

Release the lock taken by GetAndLockSystemBlock().

Returns
true on success.

◆ unlockSystemBlock()

bool cmlabs::MemoryManagerX::unlockSystemBlock ( uint32 pageID)

◆ MemoryManagement

THREAD_RET THREAD_FUNCTION_CALL MemoryManagement ( THREAD_ARG arg)
friend

Background maintenance thread entry point for MemoryManager / MemoryManagerX.

Parameters
argThe manager instance (cast internally).
Returns
Thread exit code.

Definition at line 743 of file MemoryManager.cpp.

Member Data Documentation

◆ Singleton

MemoryManagerX* cmlabs::MemoryManagerX::Singleton
static

Per-process singleton instance.

Definition at line 738 of file MemoryManager.h.


The documentation for this class was generated from the following file: