Other Parts Discussed in Thread: SYSBIOS
In the .cfg file i am using
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
How to calculate the time spent in Idle Task over a period of 1sec.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In the .cfg file i am using
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
How to calculate the time spent in Idle Task over a period of 1sec.
Hi,
Please refer to benchloop example for using APIs to measure each of their execution times.
Hi charles,
Can you please little bit more elaborate. I referred the benchloop example. Not able to get it.
Which API to use in Idle task.
Hi,
I'm not an expert in TI-RTOS. Running the benchloop example show the below benchmarks being collected.
I was thinking that you could do something similar using Timestamp_get() as used in the example to calculate the cycles in Idle function. Another method I can think of is to create a user defined idle task. Inside the idle task you set a GPIO pin high and in one of your tasks, preferably in the highest priority task, you will clear the GPIO pin. On the scope you can see relatively the elapsed time the GPIO pin is high in one second.
In the .cfg file you can insert you own Idle function as follows.
Hi charles,
i checked cpuload with GPIO.
i made one idle task like this
void idleTask (void)
{
while(1)
{
GPIOPinWrite -> high
Task_sleep(100);
}
}
over 1sec time frame i got cpu load as 50%
but when i checked in ccs the cpu load graph is showing 100%
This is unexpected. Can you help me in debugging the ccs tool issue.This graph is showing wrong result.
Hi,
Is the CPU load shown on CCS over one second? Will you be able to zoom out for a larger time span? What are the user tasks and how many tasks are you running?
Hi charles,
The above pic is not of 1sec, but I kept for longer run and observed the graph for 15 minutes. It is continuously showing 100%.
Total 6 user task are running other than idle task.
Brief discription of all user tasks
Task 1 --> based on interrupt based key press it takes some decision.
Task 2--> calculates adc values from 16 channels
Task 3 --> Perform communication with IC over i2c
Task 4--> raise alarms if some fault based on conditions is identified. A TI RTOS based queue implementation of 50 elements is used.
Task 5-->watchdog task, all other task need to report to watchdog task within its timeframe.
Task 6--> over uart talk with a peripheral.
Hi,
Before I send your question to our CCS expert, I will suggest one more experiment. How are you resetting the GPIO right now? Is it only in the highest task? Can you try to clear GPIO pin in all of your tasks. Anytime when idle task is entered, the GPIO pin is asserted but whenever it is switched out to any other non-idle task it will clear GPIO pin.
From CCS perspective, I don't know how does it know which task is a idle task and which is a non-idle task. If CCS is treating your user-defined idle task as a regular task then it may explain why CPU load is 100%. If this is the case then using user-defined idle task with pin toggle is not the correct method. But I will defer that question to CCS experts for comments.
Hi charles,
As you asked to reset the GPIO in all of the user task. I did that and attaching the results below.
in the idle task
void idleTask (void)
{
while(1)
{
GPIOPinWrite -> high
Task_sleep(100);
}
}
I modified the task_sleep as 100 , 200 and 250 and attaching the results below.
idle_task--> modify task_sleep to 200
idle_task --> modify task_sleep to 250
I dont know when i check cpu_load using ccs tool under ROV how it is calculating , is there any place where i can see the settings ?
Hi,
Independent of what ROV shows, please bear in mind that task_sleep() is in terms of system ticks. By default a tick is 1ms. When you put task_sleep(250) in your user-defined idle task, it will first set the GPIO pin and then put the task into a BLOCKING state for 250mS. While the user-defined task is in blocking state, I'm pretty sure your other 6 normal tasks are running according to how the events (e.g. semaphore or others) triggering each other to run. This is why you are showing 99% CPU load. Perhaps a more accurate way is to remove the task_sleep. After the user-defined idle task, it just sets the pin. If there are no other tasks to be run, the kernel should call other idle tasks (see below) until your normal tasks resume running upon which the GPIO pin is cleared again.
I will forward your question to our CCS experts for comments about how ROV calculates and displays the CPU load.
Hi, thanku for suggesting this experiment, The idle task was running most of the time. This boost my confidence that cpu load is not 100% which is getting reflected on CCS. Can you please forward my question to any CCS expert.
Hello Ashwini,
Can you provide the exact versions of CCS, SYS/BIOS, and XDCtools being used?
If you can also provide a test case project, that would be very helpful.
Thanks
ki
I'm not sure that it is valid to call task_sleep from an idle function.
Normally, when a task has nothing to do (e.g. it has reached a blocking call such as sem_wait or task_sleep), the scheduler gives a lower priority task a chance to run. When we get to the lowest priority and no tasks have anything to do, the scheduler wastes CPU clock cycles running round the idle loop. If you have added any user idle functions, they get called, non-stop until a task needs to do something.
If you put a sleep(100) in an idle task, where will the CPU go for 12,000,000 clock cycles?
I imagine the result is undefined.
hi,
in above messages charles corrected the method and suggested this:
Perhaps a more accurate way is to remove the task_sleep. After the user-defined idle task, it just sets the pin. If there are no other tasks to be run, the kernel should call other idle tasks until your normal tasks resume running upon which the GPIO pin is cleared again.
I have followed this method and found cpu load is not 100% as displayed in ccs under rov.
I have followed this method and found cpu load is not 100% as displayed in ccs under rov.
I'm not sure I understand. After following this method, CPU load under ROV is now not 100% anymore?
Can you provide the test case project that reproduces the issue?
Thanks
ki