CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
ProcessMemory.h File Reference

Shared-memory process ("space") table plus per-process message queues. More...

#include "MemoryManager.h"
#include "PsyTime.h"
#include "HTML.h"
Include dependency graph for ProcessMemory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cmlabs::ProcessStats
 Per-process throughput counters and recent-message rings, kept in shared memory. More...
struct  cmlabs::ProcessInfoStruct
 One process (space) record in the shared process table. More...
struct  cmlabs::ProcessMemoryStruct
 Root header of the process-memory segment: fixed process table plus queue index. More...
struct  cmlabs::MessageQueueHeader
 On-segment header of a circular message queue (legacy 32-bit layout). More...
class  cmlabs::ProcessMemory
 Accessor for the shared process table and per-process queues. More...

Namespaces

namespace  cmlabs

Macros

#define MAXPROC   64
 Maximum processes (spaces) per node.
#define MAXPROC4   256
 Maximum queues per node (MAXPROC x 4 queue types).
#define INITIALQSIZE   sizeof(MessageQueueHeader) + 2048
 Initial byte size of a newly created per-process queue.
#define CHECKPROCESSMEMORYSERIAL   if (serial != master->getProcessShmemSerial()) {if (!open()) {mutex->leave();return 0;}}
 Re-open the process segment if the master's resize serial no longer matches ours (another process re-created the segment); bails out of the calling method on failure.
Per-process queue slot indices
#define SIGNALQ_ID   0
 Signal queue slot.
#define MSGQ_ID   1
 Data-message queue slot.
#define REQQ_ID   2
 Request queue slot.
#define CMDQ_ID   3
 Command queue slot.
Process lifecycle status values (ProcessInfoStruct::status)
#define PSYPROC_ERROR   0
 Process is in an error state.
#define PSYPROC_CREATED   1
 Table entry created; process not yet started.
#define PSYPROC_INIT   2
 Process is initialising.
#define PSYPROC_IDLE   3
 Process is idle.
#define PSYPROC_READY   4
 Process is ready to run components.
#define PSYPROC_ACTIVE   5
 Process is actively running.
#define PSYPROC_SHUTTING_DOWN   6
 Process is shutting down.
#define PSYPROC_TERMINATED   7
 Process has terminated.
Queue type selectors (used by the private addToQ/waitForQ helpers)
#define CMDQ_TYPE   1
 Command queue.
#define MSGQ_TYPE   2
 Data-message queue.
#define SIGQ_TYPE   3
 Signal queue.
#define REQQ_TYPE   4
 Request queue.

Functions

static THREAD_RET THREAD_FUNCTION_CALL cmlabs::QueueTest (THREAD_ARG arg)
THREAD_RET THREAD_FUNCTION_CALL cmlabs::ProcessMemoryPerfTest (THREAD_ARG arg)

Detailed Description

Shared-memory process ("space") table plus per-process message queues.

Each Psyclone space runs as its own OS process; this segment is how they see each other. It holds a fixed array of ProcessInfoStruct records (status, heartbeat, OS pid, stats) and up to four queues per process — command, message, signal and request — implemented as circular buffers in the same segment and signalled with named cross-process semaphores. The node monitors process heartbeats here to detect crashed spaces (crash isolation: a dead process only leaves a stale table entry behind).

Warning
Shared-memory layouts; changing any struct here requires a full rebuild of all binaries (make clean && make) — see MemoryManager.h for the ABI warning.

Definition in file ProcessMemory.h.

Macro Definition Documentation

◆ CHECKPROCESSMEMORYSERIAL

#define CHECKPROCESSMEMORYSERIAL   if (serial != master->getProcessShmemSerial()) {if (!open()) {mutex->leave();return 0;}}

Re-open the process segment if the master's resize serial no longer matches ours (another process re-created the segment); bails out of the calling method on failure.

Definition at line 170 of file ProcessMemory.h.

Referenced by cmlabs::ProcessMemory::addLocalPerformanceStats(), cmlabs::ProcessMemory::addToAllSignalQs(), cmlabs::ProcessMemory::addToAllSignalQsExcept(), cmlabs::ProcessMemory::addToCmdQ(), cmlabs::ProcessMemory::addToMsgQ(), cmlabs::ProcessMemory::addToProcessStats(), cmlabs::ProcessMemory::addToReqQ(), cmlabs::ProcessMemory::addToSigQ(), cmlabs::ProcessMemory::checkProcessHeartbeats(), cmlabs::ProcessMemory::createNewProcess(), cmlabs::ProcessMemory::deleteProcess(), cmlabs::ProcessMemory::getAllProcesses(), cmlabs::ProcessMemory::getCmdQCount(), cmlabs::ProcessMemory::getMemoryUsage(), cmlabs::ProcessMemory::getMsgQCount(), cmlabs::ProcessMemory::getProcessCommandLine(), cmlabs::ProcessMemory::getProcessCreateTime(), cmlabs::ProcessMemory::getProcessID(), cmlabs::ProcessMemory::getProcessIDFromOSID(), cmlabs::ProcessMemory::getProcessName(), cmlabs::ProcessMemory::getProcessOSID(), cmlabs::ProcessMemory::getProcessStatus(), cmlabs::ProcessMemory::getQueueSizes(), cmlabs::ProcessMemory::getReqQCount(), cmlabs::ProcessMemory::getSigQCount(), cmlabs::ProcessMemory::setProcessCommandLine(), cmlabs::ProcessMemory::setProcessOSID(), cmlabs::ProcessMemory::setProcessPerfStats(), cmlabs::ProcessMemory::setProcessStatus(), cmlabs::ProcessMemory::setProcessType(), cmlabs::ProcessMemory::waitForCmdQ(), cmlabs::ProcessMemory::waitForMsgQ(), cmlabs::ProcessMemory::waitForReqQ(), and cmlabs::ProcessMemory::waitForSigQ().

◆ CMDQ_ID

#define CMDQ_ID   3

Command queue slot.

Definition at line 29 of file ProcessMemory.h.

◆ CMDQ_TYPE

#define CMDQ_TYPE   1

◆ INITIALQSIZE

#define INITIALQSIZE   sizeof(MessageQueueHeader) + 2048

Initial byte size of a newly created per-process queue.

Definition at line 153 of file ProcessMemory.h.

Referenced by cmlabs::ProcessMemory::create().

◆ MAXPROC

◆ MAXPROC4

#define MAXPROC4   256

Maximum queues per node (MAXPROC x 4 queue types).

Definition at line 33 of file ProcessMemory.h.

Referenced by cmlabs::ProcessMemory::ProcessMemory(), and cmlabs::ProcessMemory::~ProcessMemory().

◆ MSGQ_ID

#define MSGQ_ID   1

Data-message queue slot.

Definition at line 27 of file ProcessMemory.h.

◆ MSGQ_TYPE

#define MSGQ_TYPE   2

◆ PSYPROC_ACTIVE

#define PSYPROC_ACTIVE   5

Process is actively running.

Definition at line 42 of file ProcessMemory.h.

Referenced by cmlabs::ProcessMemory::checkProcessHeartbeats(), and cmlabs::ProcessMemory::create().

◆ PSYPROC_CREATED

#define PSYPROC_CREATED   1

Table entry created; process not yet started.

Definition at line 38 of file ProcessMemory.h.

Referenced by cmlabs::ProcessMemory::createNewProcess().

◆ PSYPROC_ERROR

#define PSYPROC_ERROR   0

Process is in an error state.

Definition at line 37 of file ProcessMemory.h.

◆ PSYPROC_IDLE

#define PSYPROC_IDLE   3

Process is idle.

Definition at line 40 of file ProcessMemory.h.

Referenced by cmlabs::ProcessMemory::checkProcessHeartbeats().

◆ PSYPROC_INIT

#define PSYPROC_INIT   2

Process is initialising.

Definition at line 39 of file ProcessMemory.h.

Referenced by cmlabs::PsySpace::connect().

◆ PSYPROC_READY

#define PSYPROC_READY   4

Process is ready to run components.

Definition at line 41 of file ProcessMemory.h.

Referenced by cmlabs::PsySpace::connect().

◆ PSYPROC_SHUTTING_DOWN

#define PSYPROC_SHUTTING_DOWN   6

Process is shutting down.

Definition at line 43 of file ProcessMemory.h.

◆ PSYPROC_TERMINATED

#define PSYPROC_TERMINATED   7

Process has terminated.

Definition at line 44 of file ProcessMemory.h.

Referenced by cmlabs::PsySpace::shutdown().

◆ REQQ_ID

#define REQQ_ID   2

Request queue slot.

Definition at line 28 of file ProcessMemory.h.

◆ REQQ_TYPE

#define REQQ_TYPE   4

◆ SIGNALQ_ID

#define SIGNALQ_ID   0

Signal queue slot.

Definition at line 26 of file ProcessMemory.h.

◆ SIGQ_TYPE