]> git.sur5r.net Git - freertos/commitdiff
Add new xTaskGetSystemState() API function to return raw data on each task in the...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 2 Jul 2013 12:10:16 +0000 (12:10 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 2 Jul 2013 12:10:16 +0000 (12:10 +0000)
Relegate the vTaskList() and vTaskGetRunTimeStats() functions to "sample" functions demonstrating how to use xTaskGetSystemState() to generate human readable status information.
Introduce and default configINCLUDE_STATS_FORMATTING_FUNCTIONS which must now be defined to use vTaskList() and vTaskGetRunTimeStats().

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1960 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/include/FreeRTOS.h
FreeRTOS/Source/include/task.h
FreeRTOS/Source/tasks.c

index fbd75e3d008269787c75d838526997b2234ae971..f6f4b2e8a05cec6a6cd5ea3d99eb33a2b76c2fc6 100644 (file)
@@ -588,6 +588,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
        #define configUSE_NEWLIB_REENTRANT 0\r
 #endif\r
 \r
+#ifndef configINCLUDE_STATS_FORMATTING_FUNCTIONS\r
+       #define configINCLUDE_STATS_FORMATTING_FUNCTIONS 0\r
+#endif\r
+\r
 /* For backward compatability. */\r
 #define eTaskStateGet eTaskGetState\r
 \r
index 2a16adbcf1beb92a79cc8f5fb4d741f065a7b7e1..c40a92e589fad3e855ef252ab03f3d8491f7cc4e 100644 (file)
@@ -105,6 +105,16 @@ extern "C" {
  */\r
 typedef void * xTaskHandle;\r
 \r
+/* Task states returned by eTaskGetState. */\r
+typedef enum\r
+{\r
+       eRunning = 0,   /* A task is querying the state of itself, so must be running. */\r
+       eReady,                 /* The task being queried is in a read or pending ready list. */\r
+       eBlocked,               /* The task being queried is in the Blocked state. */\r
+       eSuspended,             /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */\r
+       eDeleted                /* The task being queried has been deleted, but its TCB has not yet been freed. */\r
+} eTaskState;\r
+\r
 /*\r
  * Used internally only.\r
  */\r
@@ -138,15 +148,19 @@ typedef struct xTASK_PARAMTERS
        xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ];\r
 } xTaskParameters;\r
 \r
-/* Task states returned by eTaskGetState. */\r
-typedef enum\r
+/* Used with the xTaskGetSystemState() function to return the state of each task \r
+in the system. */\r
+typedef struct xTASK_STATUS\r
 {\r
-       eRunning = 0,   /* A task is querying the state of itself, so must be running. */\r
-       eReady,                 /* The task being queried is in a read or pending ready list. */\r
-       eBlocked,               /* The task being queried is in the Blocked state. */\r
-       eSuspended,             /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */\r
-       eDeleted                /* The task being queried has been deleted, but its TCB has not yet been freed. */\r
-} eTaskState;\r
+       xTaskHandle xHandle;                                            /* The handle of the task to which the rest of the information in the structure relates. */\r
+       const signed char *pcTaskName;                          /* A pointer to the task's name.  This valid will be invalid if the task was deleted since the structure was populated! */\r
+       unsigned portBASE_TYPE xTaskNumber;                     /* A number unique to the task. */\r
+       eTaskState eCurrentState;                                       /* The state in which the task existed when the structure was populated. */\r
+       unsigned portBASE_TYPE uxCurrentPriority;       /* The priority at which the task was running (may be inherited) when the structure was populated. */\r
+       unsigned portBASE_TYPE uxBasePriority;          /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex.  Only valid is configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */\r
+       unsigned long ulRunTimeCounter;                         /* The total run time allocated to the task so far, as defined by the run time stats clock.  See http://www.freertos.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */\r
+       unsigned short usStackHighWaterMark;            /* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */\r
+} xTaskStatusType;\r
 \r
 /* Possible return values for eTaskConfirmSleepModeStatus(). */\r
 typedef enum\r
@@ -1071,64 +1085,6 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
  */\r
 signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery );\r
 \r
-/**\r
- * task. h\r
- * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>\r
- *\r
- * configUSE_TRACE_FACILITY must be defined as 1 for this function to be\r
- * available.  See the configuration section for more information.\r
- *\r
- * NOTE: This function will disable interrupts for its duration.  It is\r
- * not intended for normal application runtime use but as a debug aid.\r
- *\r
- * Lists all the current tasks, along with their current state and stack\r
- * usage high water mark.\r
- *\r
- * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or\r
- * suspended ('S').\r
- *\r
- * @param pcWriteBuffer A buffer into which the above mentioned details\r
- * will be written, in ascii form.  This buffer is assumed to be large\r
- * enough to contain the generated report.  Approximately 40 bytes per\r
- * task should be sufficient.\r
- *\r
- * \page vTaskList vTaskList\r
- * \ingroup TaskUtils\r
- */\r
-void vTaskList( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
-\r
-/**\r
- * task. h\r
- * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>\r
- *\r
- * configGENERATE_RUN_TIME_STATS must be defined as 1 for this function\r
- * to be available.  The application must also then provide definitions\r
- * for portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and\r
- * portGET_RUN_TIME_COUNTER_VALUE to configure a peripheral timer/counter\r
- * and return the timers current count value respectively.  The counter\r
- * should be at least 10 times the frequency of the tick count.\r
- *\r
- * NOTE: This function will disable interrupts for its duration.  It is\r
- * not intended for normal application runtime use but as a debug aid.\r
- *\r
- * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total\r
- * accumulated execution time being stored for each task.  The resolution\r
- * of the accumulated time value depends on the frequency of the timer\r
- * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
- * Calling vTaskGetRunTimeStats() writes the total execution time of each\r
- * task into a buffer, both as an absolute count value and as a percentage\r
- * of the total system execution time.\r
- *\r
- * @param pcWriteBuffer A buffer into which the execution times will be\r
- * written, in ascii form.  This buffer is assumed to be large enough to\r
- * contain the generated report.  Approximately 40 bytes per task should\r
- * be sufficient.\r
- *\r
- * \page vTaskGetRunTimeStats vTaskGetRunTimeStats\r
- * \ingroup TaskUtils\r
- */\r
-void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
-\r
 /**\r
  * task.h\r
  * <PRE>unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask );</PRE>\r
@@ -1198,6 +1154,205 @@ portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter
  */\r
 xTaskHandle xTaskGetIdleTaskHandle( void );\r
 \r
+/**\r
+ * configUSE_TRACE_FACILITY must bet defined as 1 in FreeRTOSConfig.h for\r
+ * xTaskGetSystemState() to be available.\r
+ *\r
+ * xTaskGetSystemState() populates an xTaskStatusType structure for each task in\r
+ * the system.  xTaskStatusType structures contain, among other things, members \r
+ * for the task handle, task name, task priority, task state, and total amount\r
+ * of run time consumed by the task.  See the xTaskStatusType structure \r
+ * definition in this file for the full member list.\r
+ *\r
+ * NOTE:  This function is intended for debugging use only as its use results in\r
+ * the scheduler remaining suspended for an extended period.\r
+ *\r
+ * @param pxTaskStatusArray A pointer to an array of xTaskStatusType structures.  \r
+ * The array contain at least one xTaskStatusType structure for each task that \r
+ * is under the control of the RTOS.  The number of tasks under the control of \r
+ * the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.\r
+ *\r
+ * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray\r
+ * parameter.  The size is specified as the number of indexes in the array, or\r
+ * the number of xTaskStatusType structures contained in the array, not by the \r
+ * number of bytes in the array.\r
+ *\r
+ * @param pultotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in\r
+ * FreeRTOSConfig.h then *pulTotalRunTime is set by xTaskGetSystemState() to the\r
+ * total run time (as defined by the run time stats clock, see \r
+ * http://www.freertos.org/rtos-run-time-stats.html) since the target booted.\r
+ *\r
+ * @return The number of xTaskStatusType structures that were populated by \r
+ * xTaskGetSystemState().  This should equal the number returned by the\r
+ * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed\r
+ * in the uxArraySize parameter was too small.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+    // This example demonstrates how a human readable table of run time stats\r
+       // information is generated from raw data provided by xTaskGetSystemState().\r
+       // The human readable table is written to pcWriteBuffer\r
+       void vTaskGetRunTimeStats( signed char *pcWriteBuffer )\r
+       {\r
+       xTaskStatusType *pxTaskStatusArray;\r
+       volatile unsigned portBASE_TYPE uxArraySize, x;\r
+       unsigned long ulTotalRunTime, ulStatsAsPercentage;\r
+\r
+               // Make sure the write buffer does not contain a string.\r
+               *pcWriteBuffer = 0x00;\r
+\r
+               // Take a snapshot of the number of tasks in case it changes while this\r
+               // function is executing.\r
+               uxArraySize = uxCurrentNumberOfTasks;\r
+\r
+               // Allocate a xTaskStatusType structure for each task.  An array could be\r
+               // allocated statically at compile time.\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( xTaskStatusType ) );\r
+\r
+               if( pxTaskStatusArray != NULL )\r
+               {\r
+                       // Generate raw status information about each task.\r
+                       uxArraySize = xTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );\r
+\r
+                       // For percentage calculations.\r
+                       ulTotalRunTime /= 100UL;\r
+\r
+                       // Avoid divide by zero errors.\r
+                       if( ulTotalRunTime > 0 )\r
+                       {\r
+                               // For each populated position in the pxTaskStatusArray array, \r
+                               // format the raw data as human readable ASCII data\r
+                               for( x = 0; x < uxArraySize; x++ )\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
+                                       ulTotalRunTimeDiv100 has already been divided by 100.\r
+                                       ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;\r
+\r
+                                       if( ulStatsAsPercentage > 0UL )\r
+                                       {\r
+                                               sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\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
+                                               sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                       }\r
+\r
+                                       pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
+                               }\r
+                       }\r
+\r
+                       // The array is no longer needed, free the memory it consumes.\r
+                       vPortFree( pxTaskStatusArray );\r
+               }\r
+       }\r
+       </pre>\r
+ */\r
+unsigned portBASE_TYPE xTaskGetSystemState( xTaskStatusType *pxTaskStatusArray, unsigned portBASE_TYPE uxArraySize, unsigned long *pulTotalRunTime );\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>\r
+ *\r
+ * configUSE_TRACE_FACILITY and configINCLUDE_STATS_FORMATTING_FUNCTIONS must\r
+ * both be defined as 1 for this function to be available.  See the\r
+ * configuration section of the FreeRTOS.org website for more information.\r
+ *\r
+ * NOTE 1: This function will disable interrupts for its duration.  It is\r
+ * not intended for normal application runtime use but as a debug aid.\r
+ *\r
+ * Lists all the current tasks, along with their current state and stack\r
+ * usage high water mark.\r
+ *\r
+ * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or\r
+ * suspended ('S').\r
+ *\r
+ * PLEASE NOTE:\r
+ *\r
+ * This function is provided for convenience only, and is used by many of the\r
+ * demo applications.  Do not consider it to be part of the scheduler.\r
+ *\r
+ * vTaskList() calls xTaskGetSystemState(), then formats part of the\r
+ * xTaskGetSystemState() output into a human readable table that displays task\r
+ * names, states and stack usage.\r
+ *\r
+ * vTaskList() has a dependency on the sprintf() C library function that might\r
+ * bloat the code size, use a lot of stack, and provide different results on\r
+ * different platforms.  An alternative, tiny, third party, and limited\r
+ * functionality implementation of sprintf() is provided in many of the\r
+ * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note\r
+ * printf-stdarg.c does not provide a full snprintf() implementation!).\r
+ *\r
+ * It is recommended that production systems call xTaskGetSystemState()\r
+ * directly to get access to raw stats data, rather than indirectly through a\r
+ * call to vTaskList().\r
+ *\r
+ * @param pcWriteBuffer A buffer into which the above mentioned details\r
+ * will be written, in ascii form.  This buffer is assumed to be large\r
+ * enough to contain the generated report.  Approximately 40 bytes per\r
+ * task should be sufficient.\r
+ *\r
+ * \page vTaskList vTaskList\r
+ * \ingroup TaskUtils\r
+ */\r
+void vTaskList( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>\r
+ *\r
+ * configGENERATE_RUN_TIME_STATS and configINCLUDE_STATS_FORMATTING_FUNCTIONS\r
+ * must both be defined as 1 for this function to be available.  The application\r
+ * must also then provide definitions for\r
+ * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE\r
+ * to configure a peripheral timer/counter and return the timers current count\r
+ * value respectively.  The counter should be at least 10 times the frequency of\r
+ * the tick count.\r
+ *\r
+ * NOTE 1: This function will disable interrupts for its duration.  It is\r
+ * not intended for normal application runtime use but as a debug aid.\r
+ *\r
+ * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total\r
+ * accumulated execution time being stored for each task.  The resolution\r
+ * of the accumulated time value depends on the frequency of the timer\r
+ * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
+ * Calling vTaskGetRunTimeStats() writes the total execution time of each\r
+ * task into a buffer, both as an absolute count value and as a percentage\r
+ * of the total system execution time.\r
+ *\r
+ * NOTE 2:\r
+ *\r
+ * This function is provided for convenience only, and is used by many of the\r
+ * demo applications.  Do not consider it to be part of the scheduler.\r
+ *\r
+ * vTaskGetRunTimeStats() calls xTaskGetSystemState(), then formats part of the\r
+ * xTaskGetSystemState() output into a human readable table that displays the\r
+ * amount of time each task has spent in the Running state in both absolute and\r
+ * percentage terms.\r
+ *\r
+ * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function\r
+ * that might bloat the code size, use a lot of stack, and provide different\r
+ * results on different platforms.  An alternative, tiny, third party, and\r
+ * limited functionality implementation of sprintf() is provided in many of the\r
+ * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note\r
+ * printf-stdarg.c does not provide a full snprintf() implementation!).\r
+ *\r
+ * It is recommended that production systems call xTaskGetSystemState() directly\r
+ * to get access to raw stats data, rather than indirectly through a call to\r
+ * vTaskGetRunTimeStats().\r
+ *\r
+ * @param pcWriteBuffer A buffer into which the execution times will be\r
+ * written, in ascii form.  This buffer is assumed to be large enough to\r
+ * contain the generated report.  Approximately 40 bytes per task should\r
+ * be sufficient.\r
+ *\r
+ * \page vTaskGetRunTimeStats vTaskGetRunTimeStats\r
+ * \ingroup TaskUtils\r
+ */\r
+void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
+\r
 /*-----------------------------------------------------------\r
  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
  *----------------------------------------------------------*/\r
index 0dcb621b1e5725eeba5f35d766e7d1f693d1d4f1..83d9f09a36b72f61c56372817557928e48423214 100644 (file)
@@ -215,7 +215,6 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                           = ( portTic
 \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
 \r
 #endif\r
 \r
@@ -433,17 +432,16 @@ static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake ) PRIVILEGE
 static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
- * Called from vTaskList.  vListTasks details all the tasks currently under\r
- * control of the scheduler.  The tasks may be in one of a number of lists.\r
- * prvListTaskWithinSingleList accepts a list and details the tasks from\r
- * within just that list.\r
+ * Fills an xTaskStatusType structure with information on each task that is\r
+ * referenced from the pxList list (which may be a ready list, a delayed list,\r
+ * a suspended list, etc.).\r
  *\r
  * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM\r
  * NORMAL APPLICATION CODE.\r
  */\r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       static void prvListTaskWithinSingleList( const signed char *pcWriteBuffer, xList *pxList, signed char cStatus ) PRIVILEGED_FUNCTION;\r
+       static unsigned portBASE_TYPE prvListTaskWithinSingleList( xTaskStatusType *pxTaskStatusArray, xList *pxList, eTaskState eState ) PRIVILEGED_FUNCTION;\r
 \r
 #endif\r
 \r
@@ -454,7 +452,7 @@ static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TY
  */\r
 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
 \r
-       static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) PRIVILEGED_FUNCTION;\r
+       static unsigned short prvTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) PRIVILEGED_FUNCTION;\r
 \r
 #endif\r
 \r
@@ -1449,140 +1447,62 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       void vTaskList( signed char *pcWriteBuffer )\r
+       unsigned portBASE_TYPE xTaskGetSystemState( xTaskStatusType *pxTaskStatusArray, unsigned portBASE_TYPE uxArraySize, unsigned long *pulTotalRunTime )\r
        {\r
-       unsigned portBASE_TYPE uxQueue;\r
-\r
-               /* This is a VERY costly function that should be used for debug only.\r
-               It leaves interrupts disabled for a LONG time. */\r
+       unsigned portBASE_TYPE uxTask = 0, uxQueue = configMAX_PRIORITIES;\r
 \r
                vTaskSuspendAll();\r
                {\r
-                       /* Run through all the lists that could potentially contain a TCB and\r
-                       report the task name, state and stack high water mark. */\r
-\r
-                       *pcWriteBuffer = ( signed char ) 0x00;\r
-                       strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );\r
-\r
-                       uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U;\r
-\r
-                       do\r
+                       /* Is there a space in the array for each task in the system? */\r
+                       if( uxArraySize >= uxCurrentNumberOfTasks )\r
                        {\r
-                               uxQueue--;\r
-\r
-                               if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) == pdFALSE )\r
+                               /* Fill in an xTaskStatusType structure with information on each\r
+                               task in the Ready state. */\r
+                               do\r
                                {\r
-                                       prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), tskREADY_CHAR );\r
-                               }\r
-                       }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY );\r
-\r
-                       if( listLIST_IS_EMPTY( pxDelayedTaskList ) == pdFALSE )\r
-                       {\r
-                               prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, tskBLOCKED_CHAR );\r
-                       }\r
+                                       uxQueue--;\r
+                                       uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), eReady );\r
 \r
-                       if( listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) == pdFALSE )\r
-                       {\r
-                               prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, tskBLOCKED_CHAR );\r
-                       }\r
+                               }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY );\r
 \r
-                       #if( INCLUDE_vTaskDelete == 1 )\r
-                       {\r
-                               if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE )\r
-                               {\r
-                                       prvListTaskWithinSingleList( pcWriteBuffer, &xTasksWaitingTermination, tskDELETED_CHAR );\r
-                               }\r
-                       }\r
-                       #endif\r
+                               /* Fill in an xTaskStatusType structure with information on each\r
+                               task in the Blocked state. */\r
+                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( xList * ) pxDelayedTaskList, eBlocked );\r
+                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( xList * ) pxOverflowDelayedTaskList, eBlocked );\r
 \r
-                       #if ( INCLUDE_vTaskSuspend == 1 )\r
-                       {\r
-                               if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE )\r
+                               #if( INCLUDE_vTaskDelete == 1 )\r
                                {\r
-                                       prvListTaskWithinSingleList( pcWriteBuffer, &xSuspendedTaskList, tskSUSPENDED_CHAR );\r
+                                       /* Fill in an xTaskStatusType structure with information on \r
+                                       each task that has been deleted but not yet cleaned up. */\r
+                                       uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted );\r
                                }\r
-                       }\r
-                       #endif\r
-               }\r
-               xTaskResumeAll();\r
-       }\r
-\r
-#endif /* configUSE_TRACE_FACILITY */\r
-/*----------------------------------------------------------*/\r
-\r
-#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
-\r
-       void vTaskGetRunTimeStats( signed char *pcWriteBuffer )\r
-       {\r
-       unsigned portBASE_TYPE uxQueue;\r
-       unsigned long ulTotalRunTimeDiv100;\r
-\r
-               /* This is a VERY costly function that should be used for debug only.\r
-               It leaves interrupts disabled for a LONG time. */\r
-\r
-               vTaskSuspendAll();\r
-               {\r
-                       #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE\r
-                               portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );\r
-                       #else\r
-                               ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();\r
-                       #endif\r
-\r
-                       /* Divide ulTotalRunTime by 100 to make the percentage caluclations\r
-                       simpler in the prvGenerateRunTimeStatsForTasksInList() function. */\r
-                       ulTotalRunTimeDiv100 = ulTotalRunTime / 100UL;\r
-\r
-                       /* Run through all the lists that could potentially contain a TCB,\r
-                       generating a table of run timer percentages in the provided\r
-                       buffer. */\r
-\r
-                       *pcWriteBuffer = ( signed char ) 0x00;\r
-                       strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );\r
-\r
-                       uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U;\r
-\r
-                       do\r
-                       {\r
-                               uxQueue--;\r
+                               #endif\r
 \r
-                               if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) == pdFALSE )\r
+                               #if ( INCLUDE_vTaskSuspend == 1 )\r
                                {\r
-                                       prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), ulTotalRunTimeDiv100 );\r
+                                       /* Fill in an xTaskStatusType structure with information on \r
+                                       each task in the Suspended state. */\r
+                                       uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended );\r
                                }\r
-                       }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY );\r
-\r
-                       if( listLIST_IS_EMPTY( pxDelayedTaskList ) == pdFALSE )\r
-                       {\r
-                               prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, ulTotalRunTimeDiv100 );\r
-                       }\r
-\r
-                       if( listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) == pdFALSE )\r
-                       {\r
-                               prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, ulTotalRunTimeDiv100 );\r
-                       }\r
+                               #endif\r
 \r
-                       #if ( INCLUDE_vTaskDelete == 1 )\r
-                       {\r
-                               if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE )\r
+                               #if ( configGENERATE_RUN_TIME_STATS == 1)\r
                                {\r
-                                       prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, &xTasksWaitingTermination, ulTotalRunTimeDiv100 );\r
+                                       *pulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();\r
                                }\r
-                       }\r
-                       #endif\r
-\r
-                       #if ( INCLUDE_vTaskSuspend == 1 )\r
-                       {\r
-                               if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE )\r
+                               #else\r
                                {\r
-                                       prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, &xSuspendedTaskList, ulTotalRunTimeDiv100 );\r
+                                       *pulTotalRunTime = 0;\r
                                }\r
+                               #endif\r
                        }\r
-                       #endif\r
                }\r
                xTaskResumeAll();\r
+\r
+               return uxTask;\r
        }\r
 \r
-#endif /* configGENERATE_RUN_TIME_STATS */\r
+#endif /* configUSE_TRACE_FACILITY */\r
 /*----------------------------------------------------------*/\r
 \r
 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
@@ -2498,111 +2418,73 @@ tskTCB *pxNewTCB;
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       static void prvListTaskWithinSingleList( const signed char *pcWriteBuffer, xList *pxList, signed char cStatus )\r
+       static unsigned portBASE_TYPE prvListTaskWithinSingleList( xTaskStatusType *pxTaskStatusArray, xList *pxList, eTaskState eState )\r
        {\r
        volatile tskTCB *pxNextTCB, *pxFirstTCB;\r
-       unsigned short usStackRemaining;\r
-       PRIVILEGED_DATA static char pcStatusString[ configMAX_TASK_NAME_LEN + 30 ];\r
-\r
-               /* Write the details of all the TCB's in pxList into the buffer. */\r
-               listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );\r
-               do\r
-               {\r
-                       listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r
-                       #if ( portSTACK_GROWTH > 0 )\r
-                       {\r
-                               usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxEndOfStack );\r
-                       }\r
-                       #else\r
+       unsigned portBASE_TYPE uxTask = 0;\r
+\r
+               if( listCURRENT_LIST_LENGTH( pxList ) > 0 )\r
+               {                       \r
+                       listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );\r
+                       \r
+                       /* Populate an xTaskStatusType structure within the \r
+                       pxTaskStatusArray array for each task that is referenced from\r
+                       pxList.  See the definition of xTaskStatusType in task.h for the\r
+                       meaning of each xTaskStatusType structure member. */\r
+                       do\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, ( unsigned int ) usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber );\r
-                       strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatusString );\r
+                               listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r
 \r
-               } while( pxNextTCB != pxFirstTCB );\r
-       }\r
-\r
-#endif /* configUSE_TRACE_FACILITY */\r
-/*-----------------------------------------------------------*/\r
+                               pxTaskStatusArray[ uxTask ].xHandle = ( xTaskHandle ) pxNextTCB;\r
+                               pxTaskStatusArray[ uxTask ].pcTaskName = ( const signed char * ) &( pxNextTCB->pcTaskName [ 0 ] );\r
+                               pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber;\r
+                               pxTaskStatusArray[ uxTask ].eCurrentState = eState;\r
+                               pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority;\r
 \r
-#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
-\r
-       static void prvGenerateRunTimeStatsForTasksInList( const signed char *pcWriteBuffer, xList *pxList, unsigned long ulTotalRunTimeDiv100 )\r
-       {\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 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( ( char * ) pcWriteBuffer );\r
+                               #if ( configUSE_MUTEXES == 1 )\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority;\r
+                               }\r
+                               #else\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].uxBasePriority = 0;\r
+                               }\r
+                               #endif\r
 \r
-                               /* Has the task run at all? */\r
-                               if( pxNextTCB->ulRunTimeCounter == 0UL )\r
+                               #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
                                {\r
-                                       /* The task has used no CPU time at all. */\r
-                                       sprintf( ( char * ) &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName );\r
+                                       pxTaskStatusArray[ uxTask ].ulRunTimeCounter = pxNextTCB->ulRunTimeCounter;\r
                                }\r
-                               else\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
-                                       ulTotalRunTimeDiv100 has already been divided by 100. */\r
-                                       ulStatsAsPercentage = pxNextTCB->ulRunTimeCounter / ulTotalRunTimeDiv100;\r
+                                       pxTaskStatusArray[ uxTask ].ulRunTimeCounter = 0;\r
+                               }\r
+                               #endif\r
 \r
-                                       if( ulStatsAsPercentage > 0UL )\r
-                                       {\r
-                                               #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
-                                               {\r
-                                                       sprintf( ( char * ) &( 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( ( char * ) &( 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
-                                       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( ( char * ) &( 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( ( char * ) &( pcWriteBuffer[ xExistingStringLength ] ), ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter );\r
-                                               }\r
-                                               #endif\r
-                                       }\r
+                               #if ( portSTACK_GROWTH > 0 )\r
+                               {\r
+                                       ppxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxEndOfStack );\r
                                }\r
-                       }\r
+                               #else\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxStack );\r
+                               }\r
+                               #endif\r
+\r
+                               uxTask++;\r
+\r
+                       } while( pxNextTCB != pxFirstTCB );\r
+               }\r
 \r
-               } while( pxNextTCB != pxFirstTCB );\r
+               return uxTask;\r
        }\r
 \r
-#endif /* configGENERATE_RUN_TIME_STATS */\r
+#endif /* configUSE_TRACE_FACILITY */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
 \r
-       static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte )\r
+       static unsigned short prvTaskCheckFreeStackSpace( const unsigned char * pucStackByte )\r
        {\r
        register unsigned short usCount = 0U;\r
 \r
@@ -2640,7 +2522,7 @@ tskTCB *pxNewTCB;
                }\r
                #endif\r
 \r
-               uxReturn = ( unsigned portBASE_TYPE ) usTaskCheckFreeStackSpace( pcEndOfStack );\r
+               uxReturn = ( unsigned portBASE_TYPE ) prvTaskCheckFreeStackSpace( pcEndOfStack );\r
 \r
                return uxReturn;\r
        }\r
@@ -2819,6 +2701,193 @@ tskTCB *pxNewTCB;
 #endif /* portCRITICAL_NESTING_IN_TCB */\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configINCLUDE_STATS_FORMATTING_FUNCTIONS == 1 ) )\r
+\r
+       void vTaskList( signed char *pcWriteBuffer )\r
+       {\r
+       xTaskStatusType *pxTaskStatusArray;\r
+       volatile unsigned portBASE_TYPE uxArraySize, x;\r
+       unsigned long ulTotalRunTime;\r
+       char cStatus;\r
+\r
+               /*\r
+                * PLEASE NOTE:\r
+                *\r
+                * This function is provided for convenience only, and is used by many\r
+                * of the demo applications.  Do not consider it to be part of the\r
+                * scheduler.\r
+                *\r
+                * vTaskList() calls xTaskGetSystemState(), then formats part of the\r
+                * xTaskGetSystemState() output into a human readable table that\r
+                * displays task names, states and stack usage.\r
+                *\r
+                * vTaskList() has a dependency on the sprintf() C library function that\r
+                * might bloat the code size, use a lot of stack, and provide different\r
+                * results on different platforms.  An alternative, tiny, third party,\r
+                * and limited functionality implementation of sprintf() is provided in\r
+                * many of the FreeRTOS/Demo sub-directories in a file called\r
+                * printf-stdarg.c (note printf-stdarg.c does not provide a full\r
+                * snprintf() implementation!).\r
+                *\r
+                * It is recommended that production systems call xTaskGetSystemState()\r
+                * directly to get access to raw stats data, rather than indirectly\r
+                * through a call to vTaskList().\r
+                */\r
+\r
+\r
+               /* Make sure the write buffer does not contain a string. */\r
+               *pcWriteBuffer = 0x00;\r
+\r
+               /* Take a snapshot of the number of tasks in case it changes while this\r
+               function is executing. */\r
+               uxArraySize = uxCurrentNumberOfTasks;\r
+\r
+               /* Allocate an array index for each task. */\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( xTaskStatusType ) );\r
+\r
+               if( pxTaskStatusArray != NULL )\r
+               {\r
+                       /* Generate the (binary) data. */\r
+                       uxArraySize = xTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );\r
+\r
+                       /* Create a human readable table from the binary data. */\r
+                       for( x = 0; x < uxArraySize; x++ )\r
+                       {\r
+                               switch( pxTaskStatusArray[ x ].eCurrentState )\r
+                               {\r
+                               case eReady:            cStatus = tskREADY_CHAR;\r
+                                                                       break;\r
+\r
+                               case eBlocked:          cStatus = tskBLOCKED_CHAR;\r
+                                                                       break;\r
+\r
+                               case eSuspended:        cStatus = tskSUSPENDED_CHAR;\r
+                                                                       break;\r
+\r
+                               case eDeleted:          cStatus = tskDELETED_CHAR;\r
+                                                                       break;\r
+\r
+                               default:                        /* Should not get here, but it is included\r
+                                                                       to prevent static checking errors. */\r
+                                                                       cStatus = 0x00;\r
+                                                                       break;\r
+                               }\r
+\r
+                               sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxTaskStatusArray[ x ].pcTaskName, cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );\r
+                               pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
+                       }\r
+\r
+                       /* Free the array again. */\r
+                       vPortFree( pxTaskStatusArray );\r
+               }\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*----------------------------------------------------------*/\r
+\r
+#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configINCLUDE_STATS_FORMATTING_FUNCTIONS == 1 ) )\r
+\r
+       void vTaskGetRunTimeStats( signed char *pcWriteBuffer )\r
+       {\r
+       xTaskStatusType *pxTaskStatusArray;\r
+       volatile unsigned portBASE_TYPE uxArraySize, x;\r
+       unsigned long ulTotalRunTime, ulStatsAsPercentage;\r
+\r
+               /*\r
+                * PLEASE NOTE:\r
+                *\r
+                * This function is provided for convenience only, and is used by many\r
+                * of the demo applications.  Do not consider it to be part of the\r
+                * scheduler.\r
+                *\r
+                * vTaskGetRunTimeStats() calls xTaskGetSystemState(), then formats part\r
+                * of the xTaskGetSystemState() output into a human readable table that\r
+                * displays the amount of time each task has spent in the Running state\r
+                * in both absolute and percentage terms.\r
+                *\r
+                * vTaskGetRunTimeStats() has a dependency on the sprintf() C library\r
+                * function that might bloat the code size, use a lot of stack, and\r
+                * provide different results on different platforms.  An alternative,\r
+                * tiny, third party, and limited functionality implementation of\r
+                * sprintf() is provided in many of the FreeRTOS/Demo sub-directories in\r
+                * a file called printf-stdarg.c (note printf-stdarg.c does not provide\r
+                * a full snprintf() implementation!).\r
+                *\r
+                * It is recommended that production systems call xTaskGetSystemState()\r
+                * directly to get access to raw stats data, rather than indirectly\r
+                * through a call to vTaskGetRunTimeStats().\r
+                */\r
+\r
+               /* Make sure the write buffer does not contain a string. */\r
+               *pcWriteBuffer = 0x00;\r
+\r
+               /* Take a snapshot of the number of tasks in case it changes while this\r
+               function is executing. */\r
+               uxArraySize = uxCurrentNumberOfTasks;\r
+\r
+               /* Allocate an array index for each task. */\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( xTaskStatusType ) );\r
+\r
+               if( pxTaskStatusArray != NULL )\r
+               {\r
+                       /* Generate the (binary) data. */\r
+                       uxArraySize = xTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );\r
+\r
+                       /* For percentage calculations. */\r
+                       ulTotalRunTime /= 100UL;\r
+\r
+                       /* Avoid divide by zero errors. */\r
+                       if( ulTotalRunTime > 0 )\r
+                       {\r
+                               /* Create a human readable table from the binary data. */\r
+                               for( x = 0; x < uxArraySize; x++ )\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
+                                       ulTotalRunTimeDiv100 has already been divided by 100. */\r
+                                       ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;\r
+\r
+                                       if( ulStatsAsPercentage > 0UL )\r
+                                       {\r
+                                               #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
+                                               {\r
+                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
+                                               }\r
+                                               #else\r
+                                               {\r
+                                                       /* sizeof( int ) == sizeof( long ) so a smaller\r
+                                                       printf() library can be used. */\r
+                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].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( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                               }\r
+                                               #else\r
+                                               {\r
+                                                       /* sizeof( int ) == sizeof( long ) so a smaller\r
+                                                       printf() library can be used. */\r
+                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                               }\r
+                                               #endif\r
+                                       }\r
+\r
+                                       pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
+                               }\r
+                       }\r
+\r
+                       /* Free the array again. */\r
+                       vPortFree( pxTaskStatusArray );\r
+               }\r
+       }\r
+\r
+#endif /* configGENERATE_RUN_TIME_STATS */\r
 \r
 \r
 \r