mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Update the run time stats display function.
This commit is contained in:
parent
8243645ac8
commit
c66301ac9e
|
@ -1485,6 +1485,14 @@ void vTaskIncrementTick( void )
|
|||
|
||||
void vTaskSwitchContext( void )
|
||||
{
|
||||
if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE )
|
||||
{
|
||||
/* The scheduler is currently suspended - do not allow a context
|
||||
switch. */
|
||||
xMissedYield = pdTRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
traceTASK_SWITCHED_OUT();
|
||||
|
||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||
|
@ -1501,15 +1509,6 @@ void vTaskSwitchContext( void )
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE )
|
||||
{
|
||||
/* The scheduler is currently suspended - do not allow a context
|
||||
switch. */
|
||||
xMissedYield = pdTRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
taskFIRST_CHECK_FOR_STACK_OVERFLOW();
|
||||
taskSECOND_CHECK_FOR_STACK_OVERFLOW();
|
||||
|
||||
|
@ -1958,20 +1957,38 @@ tskTCB *pxNewTCB;
|
|||
listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
|
||||
do
|
||||
{
|
||||
/* Get next TCB in from the list. */
|
||||
listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
|
||||
|
||||
ulStatsAsPercentage = ( 100UL * pxNextTCB->ulRunTimeCounter ) / ulTotalRunTime;
|
||||
|
||||
if( ulStatsAsPercentage > 0UL )
|
||||
/* Divide by zero check. */
|
||||
if( ulTotalRunTime > 0UL )
|
||||
{
|
||||
sprintf( pcStatsString, ( portCHAR * ) "%s\t\t\t%lu\t\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( pcStatsString, ( portCHAR * ) "%s\t\t\t%lu\t\t\t< 1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter );
|
||||
}
|
||||
/* Has the task run at all? */
|
||||
if( pxNextTCB->ulRunTimeCounter == 0 )
|
||||
{
|
||||
/* The task has used no CPU time at all. */
|
||||
sprintf( pcStatsString, ( portCHAR * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* What percentage of the total run time as the task used?
|
||||
This will always be rounded down to the nearest integer. */
|
||||
ulStatsAsPercentage = ( 100UL * pxNextTCB->ulRunTimeCounter ) / ulTotalRunTime;
|
||||
|
||||
strcat( ( portCHAR * ) pcWriteBuffer, ( portCHAR * ) pcStatsString );
|
||||
if( ulStatsAsPercentage > 0UL )
|
||||
{
|
||||
sprintf( pcStatsString, ( portCHAR * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If the percentage is zero here then the task has
|
||||
consumed less than 1% of the total run time. */
|
||||
sprintf( pcStatsString, ( portCHAR * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter );
|
||||
}
|
||||
}
|
||||
|
||||
strcat( ( portCHAR * ) pcWriteBuffer, ( portCHAR * ) pcStatsString );
|
||||
}
|
||||
|
||||
} while( pxNextTCB != pxFirstTCB );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue