mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Add ulTaskGetRunTimeCounter and ulTaskGetRunTimePercent (#611)
Allow ulTaskGetIdleRunTimeCounter and ulTaskGetIdleRunTimePercent to be used whenever configGENERATE_RUN_TIME_STATS is enabled, as this is the only requirement for these functions to work.
This commit is contained in:
parent
8592fd23f4
commit
78319fd17e
2
.github/lexicon.txt
vendored
2
.github/lexicon.txt
vendored
|
@ -2321,6 +2321,8 @@ ulstoppedtimercompensation
|
||||||
ultablebase
|
ultablebase
|
||||||
ultaskgetidleruntimecounter
|
ultaskgetidleruntimecounter
|
||||||
ultaskgetidleruntimepercent
|
ultaskgetidleruntimepercent
|
||||||
|
ultaskgetruntimecounter
|
||||||
|
ultaskgetruntimepercent
|
||||||
ultaskhasfpucontext
|
ultaskhasfpucontext
|
||||||
ultasknotifystateclear
|
ultasknotifystateclear
|
||||||
ultasknotifytake
|
ultasknotifytake
|
||||||
|
|
|
@ -1934,6 +1934,42 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali
|
||||||
*/
|
*/
|
||||||
void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* task. h
|
||||||
|
* @code{c}
|
||||||
|
* configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask );
|
||||||
|
* configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask );
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
|
||||||
|
* available. The application must also then provide definitions for
|
||||||
|
* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
|
||||||
|
* portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
|
||||||
|
* return the timers current count value respectively. The counter should be
|
||||||
|
* at least 10 times the frequency of the tick count.
|
||||||
|
*
|
||||||
|
* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
|
||||||
|
* accumulated execution time being stored for each task. The resolution
|
||||||
|
* of the accumulated time value depends on the frequency of the timer
|
||||||
|
* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
|
||||||
|
* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
|
||||||
|
* execution time of each task into a buffer, ulTaskGetRunTimeCounter()
|
||||||
|
* returns the total execution time of just one task and
|
||||||
|
* ulTaskGetRunTimePercent() returns the percentage of the CPU time used by
|
||||||
|
* just one task.
|
||||||
|
*
|
||||||
|
* @return The total run time of the given task or the percentage of the total
|
||||||
|
* run time consumed by the given task. This is the amount of time the task
|
||||||
|
* has actually been executing. The unit of time is dependent on the frequency
|
||||||
|
* configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
|
||||||
|
* portGET_RUN_TIME_COUNTER_VALUE() macros.
|
||||||
|
*
|
||||||
|
* \defgroup ulTaskGetRunTimeCounter ulTaskGetRunTimeCounter
|
||||||
|
* \ingroup TaskUtils
|
||||||
|
*/
|
||||||
|
configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
|
||||||
|
configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* task. h
|
* task. h
|
||||||
* @code{c}
|
* @code{c}
|
||||||
|
@ -1941,13 +1977,12 @@ void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e
|
||||||
* configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
|
* configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* configGENERATE_RUN_TIME_STATS, configUSE_STATS_FORMATTING_FUNCTIONS and
|
* configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
|
||||||
* INCLUDE_xTaskGetIdleTaskHandle must all be defined as 1 for these functions
|
* available. The application must also then provide definitions for
|
||||||
* to be available. The application must also then provide definitions for
|
* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
|
||||||
* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
|
* portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
|
||||||
* to configure a peripheral timer/counter and return the timers current count
|
* return the timers current count value respectively. The counter should be
|
||||||
* value respectively. The counter should be at least 10 times the frequency of
|
* at least 10 times the frequency of the tick count.
|
||||||
* the tick count.
|
|
||||||
*
|
*
|
||||||
* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
|
* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
|
||||||
* accumulated execution time being stored for each task. The resolution
|
* accumulated execution time being stored for each task. The resolution
|
||||||
|
|
34
tasks.c
34
tasks.c
|
@ -5251,19 +5251,19 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
#endif /* configUSE_TASK_NOTIFICATIONS */
|
#endif /* configUSE_TASK_NOTIFICATIONS */
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
|
|
||||||
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void )
|
configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask )
|
||||||
{
|
{
|
||||||
return xIdleTaskHandle->ulRunTimeCounter;
|
return xTask->ulRunTimeCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
|
|
||||||
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void )
|
configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask )
|
||||||
{
|
{
|
||||||
configRUN_TIME_COUNTER_TYPE ulTotalTime, ulReturn;
|
configRUN_TIME_COUNTER_TYPE ulTotalTime, ulReturn;
|
||||||
|
|
||||||
|
@ -5275,7 +5275,7 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
/* Avoid divide by zero errors. */
|
/* Avoid divide by zero errors. */
|
||||||
if( ulTotalTime > ( configRUN_TIME_COUNTER_TYPE ) 0 )
|
if( ulTotalTime > ( configRUN_TIME_COUNTER_TYPE ) 0 )
|
||||||
{
|
{
|
||||||
ulReturn = xIdleTaskHandle->ulRunTimeCounter / ulTotalTime;
|
ulReturn = xTask->ulRunTimeCounter / ulTotalTime;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5285,7 +5285,27 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
return ulReturn;
|
return ulReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
|
#endif /* if ( configGENERATE_RUN_TIME_STATS == 1 ) */
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
|
|
||||||
|
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void )
|
||||||
|
{
|
||||||
|
return ulTaskGetRunTimeCounter( xIdleTaskHandle );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
|
|
||||||
|
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void )
|
||||||
|
{
|
||||||
|
return ulTaskGetRunTimePercent( xIdleTaskHandle );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
|
static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
|
||||||
|
|
Loading…
Reference in a new issue