|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Handle to the node's master shared-memory segment (MemoryMasterStruct). More...
#include <MemoryManager.h>
Public Member Functions | |
| MasterMemory () | |
| ~MasterMemory () | |
| bool | create (uint16 port) |
| Create the master segment for the node instance listening on port. | |
| bool | open (uint16 port) |
| Attach to an existing master segment created by another process. | |
| uint16 | getNodeID () |
| bool | setNodeID (uint16 id) |
| Set the cluster-wide node id. | |
| uint64 | getCreatedTime () |
| bool | setID (uint16 id) |
| MemoryController interface: set the node id. | |
| uint16 | getID () |
| MemoryController interface: | |
Segment resize serials | |
Each subsystem segment has a serial that is incremented whenever the segment is re-created (resized). Attached processes compare a cached serial to detect that their mapping is stale and must be re-opened. | |
| uint32 | getDynamicShmemSerial () |
| uint32 | getProcessShmemSerial () |
| uint32 | getComponentShmemSerial () |
| uint32 | getDataMapsShmemSerial () |
| uint32 | incrementDynamicShmemSerial () |
| Bump the dynamic segment serial after resize. | |
| uint32 | incrementProcessShmemSerial () |
| Bump the process segment serial after resize. | |
| uint32 | incrementComponentShmemSerial () |
| Bump the component segment serial after resize. | |
| uint32 | incrementDataMapsShmemSerial () |
| Bump the data-maps segment serial after resize. | |
Segment sizes | |
Current byte sizes of the four subsystem segments, kept here so any process can map the right amount of memory when (re-)attaching. | |
| uint64 | getDynamicShmemSize () |
| uint64 | getProcessShmemSize () |
| uint64 | getComponentShmemSize () |
| uint64 | getDataMapsShmemSize () |
| bool | setDynamicShmemSize (uint64 size) |
| Record a new dynamic segment size. | |
| bool | setProcessShmemSize (uint64 size) |
| Record a new process segment size. | |
| bool | setComponentShmemSize (uint64 size) |
| Record a new component segment size. | |
| bool | setDataMapsShmemSize (uint64 size) |
| Record a new data-maps segment size. | |
| Public Member Functions inherited from cmlabs::MemoryController | |
| MemoryController () | |
| virtual | ~MemoryController () |
Public Attributes | |
| uint16 | port |
| Node port this master segment belongs to (names all related segments). | |
Friends | |
| class | MemoryManager |
Handle to the node's master shared-memory segment (MemoryMasterStruct).
Implements the MemoryController interface used by the subsystem memories (TemporalMemory, ProcessMemory, ComponentMemory, DataMapsMemory) to read/bump the resize serials and sizes of their segments. Exactly one process per node calls create(); all others attach via open(). All getters/setters operate directly on the mapped struct under a named cross-process mutex; calls may block briefly on that mutex but never for long. The mapped memory is owned by the OS, not this object.
Definition at line 324 of file MemoryManager.h.
| cmlabs::MasterMemory::MasterMemory | ( | ) |
Definition at line 94 of file MemoryManager.cpp.
References port.
| cmlabs::MasterMemory::~MasterMemory | ( | ) |
Definition at line 100 of file MemoryManager.cpp.
References cmlabs::utils::CloseSharedMemorySegment(), and PSYCLONE_INDEX_SIZE.
| bool cmlabs::MasterMemory::create | ( | uint16 | port | ) |
Create the master segment for the node instance listening on port.
| port | Node port; used to derive the segment's global name. |
Definition at line 111 of file MemoryManager.cpp.
References cmlabs::utils::CreateSharedMemorySegment(), cmlabs::GetTimeNow(), port, PSYCLONEMASTERID, and cmlabs::utils::StringFormat().
Referenced by cmlabs::TemporalMemory::UnitTest().
| uint32 cmlabs::MasterMemory::getComponentShmemSerial | ( | ) |
Definition at line 199 of file MemoryManager.cpp.
| uint64 cmlabs::MasterMemory::getComponentShmemSize | ( | ) |
Definition at line 266 of file MemoryManager.cpp.
| uint64 cmlabs::MasterMemory::getCreatedTime | ( | ) |
Definition at line 167 of file MemoryManager.cpp.
| uint32 cmlabs::MasterMemory::getDataMapsShmemSerial | ( | ) |
Definition at line 207 of file MemoryManager.cpp.
| uint64 cmlabs::MasterMemory::getDataMapsShmemSize | ( | ) |
Definition at line 274 of file MemoryManager.cpp.
|
virtual |
Implements cmlabs::MemoryController.
Definition at line 183 of file MemoryManager.cpp.
|
virtual |
Implements cmlabs::MemoryController.
Definition at line 250 of file MemoryManager.cpp.
|
virtual |
MemoryController interface:
Implements cmlabs::MemoryController.
Definition at line 319 of file MemoryManager.cpp.
References port.
| uint16 cmlabs::MasterMemory::getNodeID | ( | ) |
Definition at line 159 of file MemoryManager.cpp.
| uint32 cmlabs::MasterMemory::getProcessShmemSerial | ( | ) |
Definition at line 191 of file MemoryManager.cpp.
| uint64 cmlabs::MasterMemory::getProcessShmemSize | ( | ) |
Definition at line 258 of file MemoryManager.cpp.
| uint32 cmlabs::MasterMemory::incrementComponentShmemSerial | ( | ) |
Bump the component segment serial after resize.
Definition at line 233 of file MemoryManager.cpp.
| uint32 cmlabs::MasterMemory::incrementDataMapsShmemSerial | ( | ) |
Bump the data-maps segment serial after resize.
Definition at line 241 of file MemoryManager.cpp.
|
virtual |
Bump the dynamic segment serial after resize.
Implements cmlabs::MemoryController.
Definition at line 217 of file MemoryManager.cpp.
| uint32 cmlabs::MasterMemory::incrementProcessShmemSerial | ( | ) |
Bump the process segment serial after resize.
Definition at line 225 of file MemoryManager.cpp.
| bool cmlabs::MasterMemory::open | ( | uint16 | port | ) |
Attach to an existing master segment created by another process.
| port | Node port identifying the segment. |
Definition at line 138 of file MemoryManager.cpp.
References cmlabs::utils::CloseSharedMemorySegment(), cmlabs::utils::OpenSharedMemorySegment(), port, PSYCLONEMASTERID, and cmlabs::utils::StringFormat().
| bool cmlabs::MasterMemory::setComponentShmemSize | ( | uint64 | size | ) |
Record a new component segment size.
| size | Bytes. |
Definition at line 298 of file MemoryManager.cpp.
| bool cmlabs::MasterMemory::setDataMapsShmemSize | ( | uint64 | size | ) |
Record a new data-maps segment size.
| size | Bytes. |
Definition at line 306 of file MemoryManager.cpp.
|
virtual |
Record a new dynamic segment size.
| size | Bytes. |
Implements cmlabs::MemoryController.
Definition at line 282 of file MemoryManager.cpp.
|
virtual |
MemoryController interface: set the node id.
| id | New id. |
Implements cmlabs::MemoryController.
Definition at line 314 of file MemoryManager.cpp.
References port.
| bool cmlabs::MasterMemory::setNodeID | ( | uint16 | id | ) |
Set the cluster-wide node id.
| id | New node id. |
Definition at line 175 of file MemoryManager.cpp.
| bool cmlabs::MasterMemory::setProcessShmemSize | ( | uint64 | size | ) |
Record a new process segment size.
| size | Bytes. |
Definition at line 290 of file MemoryManager.cpp.
|
friend |
Definition at line 325 of file MemoryManager.h.
References MemoryManager, and port.
Referenced by MemoryManager.
| uint16 cmlabs::MasterMemory::port |
Node port this master segment belongs to (names all related segments).
Definition at line 375 of file MemoryManager.h.
Referenced by create(), getID(), MasterMemory(), MemoryManager, open(), and setID().