33#error CH_DBG_STATISTICS should be defined to TRUE to use this monitoring tool
75 ti->totalTicks +=
ti->ticks[
idx];
79 ti->totalISRTicks =
currcore->kernel_stats.m_crit_isr.cumulative;
80 ti->totalTicks +=
ti->totalISRTicks;
84 ti->cpu[
idx] = (
ti->totalTicks > 0.f) ? ((
ti->ticks[
idx] * 100.f) /
ti->totalTicks) : 0.f;
101 return (
ti->totalTicks > 0.f) ? (
ti->totalISRTicks * 100.0f /
ti->totalTicks) : 0.f;
122 chprintf(
lchp,
" addr stack frestk prio refs state time \t percent name\r\n");
125 chprintf(
lchp,
"%.8lx %.8lx %6lu %4lu %4lu %9s %9lu %.2f%% \t%s\r\n",
145 chprintf(
lchp,
"Interrupt Service Routine \t\t %9lu %.2f%% \tISR\r\n",
155 chprintf(sh,
"Usage: rtos_mon\r\n");
159 chprintf(sh,
"Data reported in the RTOS_MON message:\r\n");
168 chprintf(sh,
" thread %d load: %0.1f, free stack: %d\r\n", i,
258 unsigned long long *
stkAdr = (
unsigned long long *)((
uint8_t *)
tp->wabase);
void rtos_mon_periodic_arch(void)
void rtos_mon_init_arch(void)
static uint16_t get_thread_load_x10(rttime_t thread_ticks, rttime_t total_ticks)
thread_t * thread_ref[RTOS_MON_MAX_THREADS]
Current thread identities for matching samples.
static uint8_t get_cpu_load_percent(rttime_t idle_ticks, rttime_t total_ticks)
static uint16_t get_stack_free(const thread_t *tp)
thread_t * prev_thread_ref[RTOS_MON_MAX_THREADS]
Previous thread identities for delta lookup.
static rttime_t get_thread_delta(const thread_t *tp, rttime_t current_time)
rttime_t thread_time[RTOS_MON_MAX_THREADS]
Current cumulative thread counters.
uint8_t prev_stats_valid
True after the first full sampling pass.
uint8_t prev_thread_count
Number of valid entries in previous arrays.
static struct rtos_mon_cpu_window cpu_window
rttime_t prev_isr_time
Previous cumulative ISR counter.
rttime_t prev_thread_time[RTOS_MON_MAX_THREADS]
Previous cumulative thread counters.
static struct nodeState states[UWB_SERIAL_COMM_DIST_NUM_NODES]
void chprintf(BaseSequentialStream *lchp, const char *fmt,...)
Mini printf-like functionality.
struct rtos_monitoring rtos_mon
void shell_add_entry(char *cmd_name, shell_cmd_t *cmd)
Add dynamic entry.
BaseSequentialStream shell_stream_t
System monitoring for RTOS targets return cpu load, average exec time, ...
uint8_t cpu_load
global CPU/MCU load in %
char thread_names[RTOS_MON_THREAD_NAMES+1]
string of thread names / identifiers
uint32_t core_free_memory
core free memory in bytes
uint16_t thread_free_stack[RTOS_MON_MAX_THREADS]
individual thread free stack in bytes
uint32_t heap_free_memory
Total fragmented free memory in the heap.
uint16_t thread_load[RTOS_MON_MAX_THREADS]
individual thread load in centi-percent (10*%)
uint8_t thread_name_idx
length of the string in thread_names buffer
uint8_t thread_counter
number of threads
#define RTOS_MON_MAX_THREADS
uint32_t heap_fragments
Number of fragments in the heap.
#define RTOS_MON_NAME_LEN
uint32_t heap_largest
Largest free block in the heap.
Architecture independent timing functions.
Implementation of system time functions for ChibiOS arch.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned long long uint64_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.