+ #if ( portSTACK_GROWTH > 0 )\r
+ {\r
+ usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxEndOfStack );\r
+ }\r
+ #else\r
+ {\r
+ usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxStack );\r
+ }\r
+ #endif \r
+ \r
+ sprintf( pcStatusString, ( char * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxNextTCB->pcTaskName, cStatus, ( unsigned int ) pxNextTCB->uxPriority, usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber );\r
+ strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatusString );\r
+\r
+ } while( pxNextTCB != pxFirstTCB );\r
+ }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+\r
+ static void prvGenerateRunTimeStatsForTasksInList( const signed char *pcWriteBuffer, xList *pxList, unsigned long ulTotalRunTime )\r
+ {\r
+ volatile tskTCB *pxNextTCB, *pxFirstTCB;\r
+ unsigned long ulStatsAsPercentage;\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
+ listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r
+\r
+ /* Divide by zero check. */\r
+ if( ulTotalRunTime > 0UL )\r
+ {\r
+ /* Has the task run at all? */\r
+ if( pxNextTCB->ulRunTimeCounter == 0 )\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
+ }\r
+ else\r
+ {\r
+ /* What percentage of the total run time has the task used?\r
+ This will always be rounded down to the nearest integer.\r
+ ulTotalRunTime has already been divided by 100. */\r
+ ulStatsAsPercentage = pxNextTCB->ulRunTimeCounter / ulTotalRunTime;\r
+\r
+ if( ulStatsAsPercentage > 0UL )\r
+ {\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
+ }\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
+ }\r
+ #endif\r
+ }\r
+ else\r
+ {\r
+ /* If the percentage is zero here then the task has\r
+ 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
+ }\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
+ }\r
+ #endif\r
+ }\r
+ }\r
+\r
+ strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatsString );\r
+ }\r