CPU Utilization
"Could you Implement a monitor task that ideally should be executed at the beginning of each time slice and determine the utilization factor during the previous time slice.
If the utilization factor is too high it should give warning. If we can use idle time then we can measure the utilization.
In order to set up this monitor we should this to perform a one time estimate how many idle operations can be performed in a time slice.
I probably think you can use this estimate. The monitor task should print a warning on the output if the utilization factor is higher than 90%.."
This is my requirement from I got for my internship. And I implemented one and when I check with segger systemview tool it is showing little difference. did anyone did something like this?
volatile float referencePoint = 1512.493;
volatile uint32_t tickhookcurrent = 0UL;
volatile float utilization_monitor = 0;
void vApplicationIdleHook( void )
{
/* This hook function does nothing but increment a counter. */
tickhookcurrent++;
}
void vApplicationTickHook(){
utilization_monitor = 100 - ((float) tickhookcurrent *100 / referencePoint);
tickhookcurrent = 0;
}
void monitor_task(void *argument){
char *s;
while(1){
sprintf(s, "Utilization %f", utilization_monitor);
print_function(s);
}
}
uint32_t lpt_profiler;
void task1_lowpriority(void *argument)
{
TickType_t timestamp;
while(1){
//lpt_profiler;
timestamp = xTaskGetTickCount() * portTICK_PERIOD_MS;
while((lpt_profiler = ( (xTaskGetTickCount() * portTICK_PERIOD_MS) - timestamp)) < 25*portTICK_PERIOD_MS);
SEGGER_SYSVIEW_PrintfHost("LPT task from task1");
}
vTaskDelete(NULL);
}Also If I have any task which is greater than idle task, then scheduler is not calling the idle task at all. I think the requirement is flawed. Can you give me some advice if I can do this?