I have an application I am currently developing that requires me to report the CPU usage of the system periodically. I have my code compiled (FreeRTOS 7.0.1, ARM7, IAR 6.2) with the configGENERATE_RUN_TIME_STATS flag set and I can display the stats off all tasks on my debug screen. What I am looking for is not the stats of each individual task but of the overall system. My thought was that if I can get the stats for the Idle task I can subtract the number from 100 and get the total CPU usage. My problem is that I do not know how, or if it is even possible, to get the usage stats of an individual task. One option would be to get the stats for all the tasks and parse out the idle task information but that would be a waste of resources which I don’t have.
The one thing I tried, that didn’t seem to work well, is to set up idle and tick hook functions that incremented a uint32 variable every time they are entered. I used these values to try to calculate the percentage of time in idle. Unfortunately the values I calculated did not correspond to the RTOS task stats.
Does anyone have any suggestions?