We are able to gather CPU statistics and dump them wherever we want via printer. Current CPU statistics gathering:
Our processor usage is limited to:
Applications and Services are registered on bus and are processing data on demand. Workers should also process data on demand, but do not have bus - but communicate via custom bindings. Workers are bound to Services. Threads are naked FreeRTOS threads, for our needs its: Idle task, Timer task - these do not have any rule how should be implemented. IRQ's are very processing specific.
For Applications and Services we can measure:
defined in: module-os/FreeRTOS/perf.h, on each context switch saves data in memory pool for each task.
used in:
Two approaches were tested:
The first approach resulted in quite a lot of data, especially in the moments when the processor was fully loaded. With filtering out useless information it resulted in ~60 samples per 100ms when in idle, while having thousands when actual processing was happening (i.e. rendering). This resulted in pretty graphing capabilities, but was not useable for storage, as we could easily gather thousands kB per 100ms The second approach sums time and context switches per task from the last request. This way we do not know what exact tasks fight for the CPU attention, but have overall smoothened characteristics.
The second approach is more convenient to both:
There is sys::cpu::Printer class in CpuStatistics for use. Depending of needs curently it can either:
Currently we do not measure time spent in IRQs, this could be easily achieved by: