hi ,
I am trying to use statistical module for deriving the CPU load, but i have some question that I would ask the expert here.
Currently , my system(tickless) is running quite a number of thread, I understand that the statistical module could be able to calculate the time for each thread and hence derived the CPU Load time.
My question is if it also work with Interrupt design . An example is using an interrupt to spin of couple of thread …, does the statistical module work? under what kind of situation that this statistical module cannot be use.
i am a newbie , and i hope that expert here could guide me along.
Thank you and Best Regards
albert
Questions on CPU load using statistic module.
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Questions on CPU load using statistic module.
Hi,
The stats module does not take into account the time spent in ISRs but that should be small compared to time spent into threads. ISR time is added to the threads preempted by the IRQ. Over time ISR time is statistically spread on all threads proportionally to their CPU usage.
Giovanni
The stats module does not take into account the time spent in ISRs but that should be small compared to time spent into threads. ISR time is added to the threads preempted by the IRQ. Over time ISR time is statistically spread on all threads proportionally to their CPU usage.
Giovanni
-
- Posts: 77
- Joined: Sat Mar 19, 2016 8:07 pm
- Been thanked: 17 times
Re: Questions on CPU load using statistic module.
I mostly use Cortex-M0 based MCUs. They are missing some debugging hardware element that is required for the ChibiOS statistics module to work. So this is how I get load statistics instead:
I modify the idle thread enter and exit hooks, disable a GPIO on idle enter, enable the GPIO on idle leave. Then I can view the GPIO on the oscilloscope, every time the GPIO is high, ChibiOS is under load and not idle. I can then let the scope calculate the load percentage.
Also I can use the scope trigger system to find the longest consecutive load sequence in some test scenario. I can also use the other channels of the scope to compare external signals that influence my system to the load at that moment. Or compare the reaction latency of the system to an external event (as observed on the other scope channels) to the load situation at that moment.
This works quite well for my needs. If needed it could even be extended to show different threads on different GPIOs or similar.
I modify the idle thread enter and exit hooks, disable a GPIO on idle enter, enable the GPIO on idle leave. Then I can view the GPIO on the oscilloscope, every time the GPIO is high, ChibiOS is under load and not idle. I can then let the scope calculate the load percentage.
Also I can use the scope trigger system to find the longest consecutive load sequence in some test scenario. I can also use the other channels of the scope to compare external signals that influence my system to the load at that moment. Or compare the reaction latency of the system to an external event (as observed on the other scope channels) to the load situation at that moment.
This works quite well for my needs. If needed it could even be extended to show different threads on different GPIOs or similar.
Re: Questions on CPU load using statistic module.
Giovanni wrote:Hi,
The stats module does not take into account the time spent in ISRs but that should be small compared to time spent into threads. ISR time is added to the threads preempted by the IRQ. Over time ISR time is statistically spread on all threads proportionally to their CPU usage.
Giovanni
Thank for the clarification. I will try out the stat module. In case , i face any more problem that I could not solve.... Pardon me for pestering you again.
Re: Questions on CPU load using statistic module.
electronic_eel wrote:I mostly use Cortex-M0 based MCUs. They are missing some debugging hardware element that is required for the ChibiOS statistics module to work. So this is how I get load statistics instead:
I modify the idle thread enter and exit hooks, disable a GPIO on idle enter, enable the GPIO on idle leave. Then I can view the GPIO on the oscilloscope, every time the GPIO is high, ChibiOS is under load and not idle. I can then let the scope calculate the load percentage.
Also I can use the scope trigger system to find the longest consecutive load sequence in some test scenario. I can also use the other channels of the scope to compare external signals that influence my system to the load at that moment. Or compare the reaction latency of the system to an external event (as observed on the other scope channels) to the load situation at that moment.
This works quite well for my needs. If needed it could even be extended to show different threads on different GPIOs or similar.
This look like a hardware solution , I am using M4 based MCUs , so far the compiler/linker never complain when i use the Statistic module, it throwing some number and I think i could use your method to verify if they are indeed correct. Thank you !!!
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Questions on CPU load using statistic module.
The cortex-m port uses the internal SWT cycles couter for time measurement, this is missing on the cortex-m0, this is why that service is not available on M0s.
With some work it could be made to work with some other STM32 counter, also the TIMx used for systick.
Giovanni
With some work it could be made to work with some other STM32 counter, also the TIMx used for systick.
Giovanni
Who is online
Users browsing this forum: No registered users and 20 guests