I have to evaluate the Task execution time with Interrupt time to be subtracted. I have all the ISR time instrumented and readily available. Each task measurement data is available. I just need to get the task details that is interrupted by ISR. I am new to the FreeRTOS.
Can you please provide your suggestions. The task statistics from FreeRTOS cannot be used.
Can you measure the task execution time and ISR execution time separately then subtract one from the other?
Thank you for the response. My issue is during the ISR execution time, how to know about which task that was interrupted so that that task measured time can be subtracted with the ISR time.
Tracealyzer is exactly the tool you are looking for.
There is the current task pointer.
Can I access the current task pointer from the ISR routine.
How to access this info
Code that wants to access and manipulate the usage structures should be in freertos_tasks_c_additions.h which tasks.c will include when you define configINCLUDE_FREERTOS_TASK_c_ADDITONS_H to 1. Code in that file can assess variable pxCurrentTCB directly, and the members of the TCB that it points to since it has that definition available.
I put in that file an ISR start routine and an ISR end routine that all (non-trivial) ISRs call at start and end to allow me to keep track of time spent in each ISR and correct task time to not include at least most of the ISR execution time.
Thank you Richard for the answers. I already have a global variable that holds the ISR runtime when any interrupt is executed.
Can I straightway use this value in the file you have specified :
Taskruntime = Maximumruntime - taskswitchedtime - ISR time . Then I clear the ISR global value to zero.
Is this assumption correct.
Thank you for your patience.
My method was based on using the Run Time stats capability. If you just have a single global which totals all the time spent in any task, THAT time will simply be the total time the scheduler has run so all you need to do is tally up how much time has been spent in ISRs and subtract that from your total. Not sure what use your global task usage time is, as that will include all the time that the IDLE task has used.
Thank you Richard. I can work with this solution you have suggested. Additionally can I make use of traceTASK_SWITCHED_IN ( take time stamp) and traceTASK_SWITCHED_OUT ( take another time stamp). Does this difference will provide me with the specific task execution time ?
It seems you are trying very hard to recreate what FreeRTOS
already supplies with the run time stats feature. That is possible, but harder as FreeRTOS has a member in the TCB to use, but you will need to translate the TCB I’d into an index into some other structure to record your data. If you are only concerned about ONE task, maybe it is quicker, but otherwise why not use the Run time stats, with extensions added through the extensions system.