holoscan::CPUResourceMonitor
holoscan::CPUResourceMonitor
CPUResourceMonitor class.
This class is responsible for monitoring the CPU resources. It provides the information about the CPU resources (through holoscan::CPUInfo) to the SystemResourceManager class.
The following holoscan::CPUMetricFlag flags are supported:
DEFAULT: Default CPU metrics (CORE_COUNT | CPU_COUNT | AVAILABLE_PROCESSOR_COUNT)CORE_COUNT: Number of cores (num_cores)CPU_COUNT: Number of CPUs (num_cpus)AVAILABLE_PROCESSOR_COUNT: Number of available processors (num_processors)CPU_USAGE: CPU usage (cpu_usage)MEMORY_USAGE: Memory usage (memory_total, memory_free, memory_available, memory_usage)SHARED_MEMORY_USAGE: Shared memory usage (shared_memory_total, shared_memory_free, shared_memory_available, shared_memory_usage)ALL: All CPU metrics
CPU usage information is based on the /proc/stat file and it calculates the CPU usage between the current and the previous CPU usage information, so it is necessary to call update() method at least once before calling cpu_info() method.
Example:
Example
Constructors
CPUResourceMonitor
Construct a new CPUResourceMonitor object.
This constructor creates a new CPUResourceMonitor object.
Parameters
The topology context (from holoscan::Topology::context()).
The metric flags (default: CORE_COUNT | CPU_COUNT | AVAILABLE_PROCESSOR_COUNT)
Destructor
~CPUResourceMonitor
Methods
metric_flags
Mutable
Const
Set metric flags.
This function sets the metric flags.
Parameters
The metric flags
update
Update the CPU information and cache it
Update the CPU information
Update the CPU information and cache it.
This function updates information for the CPU with the given metric flags and returns the CPU information. If the metric flags are not provided, the existing metric flags are used. It also caches the CPU information.
Returns: The CPU information.
Parameters
The metric flags.
cpu_info
Get the CPU information.
If the metric flags are provided, it returns the CPU information based on the given metric flags. If the metric flags are not provided, it returns the cached CPU information.
Returns: The CPU information.
Parameters
The metric flags.
cpu_set
Get the CPU set.
The returned value (cpu_set_t) can be used to check whether the given CPU is available or not.
See https://linux.die.net/man/2/sched_getaffinity for more details.
Example:
Returns: The CPU set.
Example