From: richardbarry Date: Sun, 19 May 2013 09:56:47 +0000 (+0000) Subject: Update the code that generates the run time stats strings so the pcStatsString[]... X-Git-Tag: V7.5.0~91 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ff878c40a9312a9584ccc81a9d850200220ec62a;p=freertos Update the code that generates the run time stats strings so the pcStatsString[] array is not required. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1899 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index 630645d66..f892f7caf 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -202,7 +202,6 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime = ( portTic #if ( configGENERATE_RUN_TIME_STATS == 1 ) - PRIVILEGED_DATA static char pcStatsString[ 50 ] ; PRIVILEGED_DATA static unsigned long ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ PRIVILEGED_DATA static unsigned long ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ static void prvGenerateRunTimeStatsForTasksInList( const signed char *pcWriteBuffer, xList *pxList, unsigned long ulTotalRunTimeDiv100 ) PRIVILEGED_FUNCTION; @@ -2472,22 +2471,25 @@ tskTCB *pxNewTCB; { volatile tskTCB *pxNextTCB, *pxFirstTCB; unsigned long ulStatsAsPercentage; + size_t xExistingStringLength; /* Write the run time stats of all the TCB's in pxList into the buffer. */ listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); do { - /* Get next TCB in from the list. */ + /* Get next TCB from the list. */ listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); /* Divide by zero check. */ if( ulTotalRunTimeDiv100 > 0UL ) { + xExistingStringLength = strlen( pcWriteBuffer ); + /* Has the task run at all? */ if( pxNextTCB->ulRunTimeCounter == 0UL ) { /* The task has used no CPU time at all. */ - sprintf( pcStatsString, ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName ); + sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName ); } else { @@ -2500,13 +2502,13 @@ tskTCB *pxNewTCB; { #ifdef portLU_PRINTF_SPECIFIER_REQUIRED { - sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage ); + sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage ); } #else { /* sizeof( int ) == sizeof( long ) so a smaller printf() library can be used. */ - sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); + sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); } #endif } @@ -2516,19 +2518,17 @@ tskTCB *pxNewTCB; consumed less than 1% of the total run time. */ #ifdef portLU_PRINTF_SPECIFIER_REQUIRED { - sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter ); + sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter ); } #else { /* sizeof( int ) == sizeof( long ) so a smaller printf() library can be used. */ - sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter ); + sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter ); } #endif } } - - strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatsString ); } } while( pxNextTCB != pxFirstTCB );