]> git.sur5r.net Git - freertos/commitdiff
Update the code that generates the run time stats strings so the pcStatsString[]...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 19 May 2013 09:56:47 +0000 (09:56 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 19 May 2013 09:56:47 +0000 (09:56 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1899 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/tasks.c

index 630645d66ff74a55b109a98919460965c2dc2fe6..f892f7caf394981168ae6f11636d5c85d53a04aa 100644 (file)
@@ -202,7 +202,6 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                           = ( portTic
 \r
 #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
 \r
-       PRIVILEGED_DATA static char pcStatsString[ 50 ] ;\r
        PRIVILEGED_DATA static unsigned long ulTaskSwitchedInTime = 0UL;        /*< Holds the value of a timer/counter the last time a task was switched in. */\r
        PRIVILEGED_DATA static unsigned long ulTotalRunTime = 0UL;                              /*< Holds the total amount of execution time as defined by the run time counter clock. */\r
        static void prvGenerateRunTimeStatsForTasksInList( const signed char *pcWriteBuffer, xList *pxList, unsigned long ulTotalRunTimeDiv100 ) PRIVILEGED_FUNCTION;\r
@@ -2472,22 +2471,25 @@ tskTCB *pxNewTCB;
        {\r
        volatile tskTCB *pxNextTCB, *pxFirstTCB;\r
        unsigned long ulStatsAsPercentage;\r
+       size_t xExistingStringLength;\r
 \r
                /* Write the run time stats of all the TCB's in pxList into the buffer. */\r
                listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );\r
                do\r
                {\r
-                       /* Get next TCB in from the list. */\r
+                       /* Get next TCB from the list. */\r
                        listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r
 \r
                        /* Divide by zero check. */\r
                        if( ulTotalRunTimeDiv100 > 0UL )\r
                        {\r
+                               xExistingStringLength = strlen( pcWriteBuffer );\r
+\r
                                /* Has the task run at all? */\r
                                if( pxNextTCB->ulRunTimeCounter == 0UL )\r
                                {\r
                                        /* The task has used no CPU time at all. */\r
-                                       sprintf( pcStatsString, ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName );\r
+                                       sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName );\r
                                }\r
                                else\r
                                {\r
@@ -2500,13 +2502,13 @@ tskTCB *pxNewTCB;
                                        {\r
                                                #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
                                                {\r
-                                                       sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage );\r
+                                                       sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage );\r
                                                }\r
                                                #else\r
                                                {\r
                                                        /* sizeof( int ) == sizeof( long ) so a smaller\r
                                                        printf() library can be used. */\r
-                                                       sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
+                                                       sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
                                                }\r
                                                #endif\r
                                        }\r
@@ -2516,19 +2518,17 @@ tskTCB *pxNewTCB;
                                                consumed less than 1% of the total run time. */\r
                                                #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
                                                {\r
-                                                       sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter );\r
+                                                       sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter );\r
                                                }\r
                                                #else\r
                                                {\r
                                                        /* sizeof( int ) == sizeof( long ) so a smaller\r
                                                        printf() library can be used. */\r
-                                                       sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter );\r
+                                                       sprintf( &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter );\r
                                                }\r
                                                #endif\r
                                        }\r
                                }\r
-\r
-                               strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatsString );\r
                        }\r
 \r
                } while( pxNextTCB != pxFirstTCB );\r