[HELP] How to get the cpuload of a each thread or task and overall cpuload in NuttX
Description
Hi,
I am working on an application where I need to accurately measure the CPU load of individual threads/tasks, as well as the overall system CPU load in NuttX.
I have attempted to use the clock_cpuload() function to retrieve this information. However, I'm encountering an issue where clock_cpuload() consistently returns the same value for all tasks, regardless of their actual CPU usage.
Could someone please advise on the correct approach to obtain per-thread/task CPU load and the overall system CPU load in NuttX? Are there alternative methods or considerations I should be aware of when using clock_cpuload()? Specifically, am I missing any necessary setup or usage details?
Any insights or examples would be greatly appreciated.
Thanks & Regards, Harish Nayineni
Verification
- [x] I have verified before submitting the report.
Hi @harishn6,
Very interesting project!
Did you enable all need CONFIGs necessary by clock_cpuload() to work (sched/sched/sched_cpuload.c)? I think so since you found that function that is not commonly used by other drivers.
I think the best way to measure precisely is using something like debugger tracer, i.e. JLINK RTT that is supported by NuttX (look at drivers/segger) because the clock_cpuload() by itself will introduce some overhead.
Maybe @xiaoxiang781216 @raiden00pl or @jkivilin have some idea why you are getting the same values for all tasks.
Hello @xiaoxiang781216 ,@raiden00pl ,@jkivilin I would like to know any help you can provide on above discussion.
@Donny9 since Xiang seems busy, could you please take a look?
clock_cpuload with 0(idle task) return cpu loading, other pid return the load of the specific thread. So, your usage is right, do you enable the related config correctly? Does ps already report the correct value?