From 7d8ab354850177f14998f71850fc5393ee04776e Mon Sep 17 00:00:00 2001 From: Ehud Machluf Date: Mon, 9 Sep 2024 11:27:55 +0300 Subject: [PATCH] Fix getting stats on the current running task running time via vTaskGetInfo. This is especially important if the current task is stuck --- tasks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasks.c b/tasks.c index 483ad29e6..aa447511d 100644 --- a/tasks.c +++ b/tasks.c @@ -6171,6 +6171,16 @@ static void prvCheckTasksWaitingTermination( void ) #if ( configGENERATE_RUN_TIME_STATS == 1 ) { pxTaskStatus->ulRunTimeCounter = pxTCB->ulRunTimeCounter; + if( pxTCB == pxCurrentTCB ) + { + uint32_t ulCurrentTotalRunTime; +#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ulCurrentTotalRunTime ); +#else + ulCurrentTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); +#endif + pxTaskStatus->ulRunTimeCounter += ( ulCurrentTotalRunTime - ulTaskSwitchedInTime ); + } } #else {