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

Bookkeeping record for a single managed thread. More...

#include <ThreadManager.h>

Public Attributes

uint32 id
 ThreadManager-assigned slot ID (index into the stats array).
uint64 created
 Creation time (microseconds, GetTimeNow()); 0 = slot unused/invalid.
uint32 status
 Lifecycle state (THREAD_NONE/INIT/RUNNING/PAUSED/INTERRUPTED/TERMINATED).
uint32 osID
 Operating-system thread ID (as reported by the OS, not the slot ID).
ThreadHandle hThread
 Native handle (HANDLE on Windows, pthread_t wrapper on POSIX).
THREAD_FUNCTION func
 Entry function, retained so InterruptThread() can restart the thread.
void * args
 Argument passed to func, retained for restart.
uint64 time [10]
 Rolling timestamps of the last 10 statistics samples (newest first).
uint64 currentCPUTicks [10]
 Rolling CPU-tick readings matching time (newest first).

Detailed Description

Bookkeeping record for a single managed thread.

One ThreadStats lives in the ThreadManager's contiguous storage block per thread slot. The time / currentCPUTicks arrays are rolling windows: index 0 is the most recent sample and each monitoring pass shifts the history down, giving up to 10 samples for CPU-load estimation.

Note
This is a plain POD copied around by value; it must stay trivially copyable because the storage block is (re)allocated with malloc/memcpy.

Definition at line 108 of file ThreadManager.h.

Member Data Documentation

◆ args

void* cmlabs::ThreadStats::args

◆ created

◆ currentCPUTicks

uint64 cmlabs::ThreadStats::currentCPUTicks[10]

Rolling CPU-tick readings matching time (newest first).

Definition at line 117 of file ThreadManager.h.

Referenced by cmlabs::ThreadManager::addLocalThreadStats(), and cmlabs::ThreadManager::threadMonitoring().

◆ func

◆ hThread

◆ id

uint32 cmlabs::ThreadStats::id

◆ osID

uint32 cmlabs::ThreadStats::osID

Operating-system thread ID (as reported by the OS, not the slot ID).

Definition at line 112 of file ThreadManager.h.

Referenced by cmlabs::ThreadManager::createThread(), cmlabs::NetworkChannel::endConnection(), cmlabs::ThreadManager::getLocalThreadID(), and cmlabs::ThreadManager::threadMonitoring().

◆ status

◆ time

uint64 cmlabs::ThreadStats::time[10]

Rolling timestamps of the last 10 statistics samples (newest first).

Definition at line 116 of file ThreadManager.h.

Referenced by cmlabs::ThreadManager::addLocalThreadStats(), and cmlabs::ThreadManager::threadMonitoring().


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