Enhance vTaskList() and vTaskGetRunTimeStats

Barry, The vTaskList() and vTaskGetRunTimeStats() can be enhanced to not use pcStatsString at all, which will reduce RAM footprint by 100 bytes.  The execution speed will also benefit.
Instead of sprintf() and strcat(), we can use this:
sprintf(vBuff + strlen(vBuff), “%s …”, taskName); This way, sprintf will append to vBuff rather than using sprintf and strcat().  I’ve also enhanced the vTaskGetRunTimeStats() by adding vTaskResetRunTimeStats().  Without resetting the run time counters, it is difficult to see CPU utilization of recent activity.  This change is really trivial, which is to reset Task counters, ulRunTimeCounter, and have a Portable function to reset the hardware timer. Let me know if you’d like me to post code.  I’ve got a working/tested version that also follows your coding standards. Preet

Enhance vTaskList() and vTaskGetRunTimeStats

Yes!  Please post the code.  The best place would be the “any other” forum in the FreeRTOS Interactive site: http://interactive.freertos.org/forums/135282-any-other-files-any-other-manufacturers-any-other-business It would also be an idea to post a feature request in the SourceForge tracker to point to your FreeRTOS interactive post too, to ensure it doesn’t get lost in the noise. Regards.

Enhance vTaskList() and vTaskGetRunTimeStats

Hi, i did some modifications, too: static void prvListTaskWithinSingleList( const signed char *pcWriteBuffer, xList *pxList, signed char cStatus )
{
volatile tskTCB *pxNextTCB, *pxFirstTCB;
unsigned short usStackRemaining; /* Write the details of all the TCB’s in pxList into the buffer. */
listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
do
{
listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
#if ( portSTACK_GROWTH > 0 )
{
usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxEndOfStack );
}
#else
{
usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxStack );
}
#endif sprintf( pcStatusString, ( char * ) “%24stt%ct%ut%ut%urn”, pxNextTCB->pcTaskName, cStatus, ( unsigned int ) pxNextTCB->uxPriority, usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber );
strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatusString ); } while( pxNextTCB != pxFirstTCB );
} otherwise the prints in the console windows get messed up by variing task name lengths. is there a way to sort the output of vTaskList eg by task number so that repetive prints only vary in the numbers printed and not in the task position in the printed table?

Enhance vTaskList() and vTaskGetRunTimeStats

by the way: where is the code uploaded by preetpal? did it made it to a freertos release? thanks

Enhance vTaskList() and vTaskGetRunTimeStats

I have already made updates to remove pcStatsString. The next release will generate the run time and task stats as binary data, then have the existing functions that format the data into a human readable form from the binary data as external utility functions – thus removing sprintf() from tasks.c.  Users are then free to use their own functions to format the data in any way they wish from the binary data, or indeed just use the binary data itself. Regards.