MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / vTaskList

Function vTaskList

tasks.c:5393–5492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5391#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
5392
5393 void vTaskList( char * pcWriteBuffer )
5394 {
5395 TaskStatus_t * pxTaskStatusArray;
5396 UBaseType_t uxArraySize, x;
5397 char cStatus;
5398
5399 /*
5400 * PLEASE NOTE:
5401 *
5402 * This function is provided for convenience only, and is used by many
5403 * of the demo applications. Do not consider it to be part of the
5404 * scheduler.
5405 *
5406 * vTaskList() calls uxTaskGetSystemState(), then formats part of the
5407 * uxTaskGetSystemState() output into a human readable table that
5408 * displays task: names, states, priority, stack usage and task number.
5409 * Stack usage specified as the number of unused StackType_t words stack can hold
5410 * on top of stack - not the number of bytes.
5411 *
5412 * vTaskList() has a dependency on the sprintf() C library function that
5413 * might bloat the code size, use a lot of stack, and provide different
5414 * results on different platforms. An alternative, tiny, third party,
5415 * and limited functionality implementation of sprintf() is provided in
5416 * many of the FreeRTOS/Demo sub-directories in a file called
5417 * printf-stdarg.c (note printf-stdarg.c does not provide a full
5418 * snprintf() implementation!).
5419 *
5420 * It is recommended that production systems call uxTaskGetSystemState()
5421 * directly to get access to raw stats data, rather than indirectly
5422 * through a call to vTaskList().
5423 */
5424
5425
5426 /* Make sure the write buffer does not contain a string. */
5427 *pcWriteBuffer = ( char ) 0x00;
5428
5429 /* Take a snapshot of the number of tasks in case it changes while this
5430 * function is executing. */
5431 uxArraySize = uxCurrentNumberOfTasks;
5432
5433 /* Allocate an array index for each task. NOTE! if
5434 * configSUPPORT_DYNAMIC_ALLOCATION is set to 0 then pvPortMalloc() will
5435 * equate to NULL. */
5436 pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation allocates a struct that has the alignment requirements of a pointer. */
5437
5438 if( pxTaskStatusArray != NULL )
5439 {
5440 /* Generate the (binary) data. */
5441 uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL );
5442
5443 /* Create a human readable table from the binary data. */
5444 for( x = 0; x < uxArraySize; x++ )
5445 {
5446 switch( pxTaskStatusArray[ x ].eCurrentState )
5447 {
5448 case eRunning:
5449 cStatus = tskRUNNING_CHAR;
5450 break;

Callers 1

MPU_vTaskListFunction · 0.85

Calls 4

uxTaskGetSystemStateFunction · 0.85
prvWriteNameToBufferFunction · 0.85
pvPortMallocFunction · 0.50
vPortFreeFunction · 0.50

Tested by

no test coverage detected