Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

FreeRTOS 10.0.0 Problem: vTaskList is truncating information about the calling task

Posted by derks2 on December 11, 2017

I am using vTaskList to minitor reaming stat for each task. Under version 9.0.0 all of the tasks information is being returned, but under 10,0.0 the calling task information is being truncated and the is combuned with the next task in the list.

Version 9.0.0 ~~~ Name Status Pri Free No.


Diag R 2 403 3 IDLE R 0 108 10 Tmr Svc B 4 191 11 Led B 2 36 2 MB/TCPAcpt B 2 218 7 TCP/IP Stack B 2 596 1 RS4852 S 2 474 6 CC S 2 463 8 Qsec S 2 191 9 RS4850 S 2 474 4 RS4851 S 2 474 5 ~~~

Version 10.0.0 ~~~ Name Status Pri Free No.


Diag IDLE R 0 108 10 Tmr Svc B 4 191 11 Led B 2 36 2 MB/TCPAcpt B 2 218 7 TCP/IP Stack B 2 596 1 RS4852 S 2 474 6 CC S 2 463 8 Qsec S 2 191 9 RS4850 S 2 474 4 RS4851 S 2 474 5 ~~~

After I investigated the problem I discovered that version 9.0.0 returns a "eReady" value for the tasks "eCurrentState" where version 10.0.0 returnes a "eRunning" value.

The switch statement in vTaskList does not have a case statement for "eRunning" and thus falls into the default case and "cStatus" gets set to a null character '0'.

~~~ /* Generate the (binary) data. */ uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL );

		/* Create a human readable table from the binary data. */
		for( x = 0; x < uxArraySize; x++ )
		{
			switch( pxTaskStatusArray[ x ].eCurrentState )
			{
				case eRunning:		cStatus = tskRUNNING_CHAR;
                                                        break;

				case eReady:		cStatus = tskREADY_CHAR;
                                                        break;

				case eBlocked:		cStatus = tskBLOCKED_CHAR;
                                                        break;

				case eSuspended:	cStatus = tskSUSPENDED_CHAR;
                                                        break;

				case eDeleted:		cStatus = tskDELETED_CHAR;
                                                        break;

				default:			/* Should not get here, but it is included
                                                        to prevent static checking errors. */
                                                        cStatus = 0x00;
                                                        break;
			}

			/* Write the task name to the string, padding with spaces so it
			can be printed in tabular form more easily. */
			pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );

			/* Write the rest of the string. */
			sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );
			pcWriteBuffer += strlen( pcWriteBuffer );
		}

~~~

The sprintf statement puts a null terminator after the name of the first tasks and looses the remainder of the data.

I modified the code to fix the problem. I needed a way to show that the task is running so I used 'E' to indicating that it is "Executing"

The following are snippets of my changes to the file: tasks.c":

~~~

define tskRUNNING_CHAR ( 'E' )
define tskBLOCKED_CHAR ( 'B' )
define tskREADY_CHAR ( 'R' )
define tskDELETED_CHAR ( 'D' )
define tskSUSPENDED_CHAR ( 'S' )

~~~

~~~ /* Generate the (binary) data. */ uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL );

		/* Create a human readable table from the binary data. */
		for( x = 0; x < uxArraySize; x++ )
		{
			switch( pxTaskStatusArray[ x ].eCurrentState )
			{
				case eRunning:		cStatus = tskRUNNING_CHAR;
                                                        break;

				case eReady:		cStatus = tskREADY_CHAR;
                                                        break;

				case eBlocked:		cStatus = tskBLOCKED_CHAR;
                                                        break;

				case eSuspended:	cStatus = tskSUSPENDED_CHAR;
                                                        break;

				case eDeleted:		cStatus = tskDELETED_CHAR;
                                                        break;

				default:			/* Should not get here, but it is included
                                                        to prevent static checking errors. */
                                                        cStatus = 0x00;
                                                        break;
			}

			/* Write the task name to the string, padding with spaces so it
			can be printed in tabular form more easily. */
			pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );

			/* Write the rest of the string. */
			sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );
			pcWriteBuffer += strlen( pcWriteBuffer );
		}

~~~

Result after the fix ~~~ Name Status Pri Free No.


Diag E 2 403 3 IDLE R 0 108 10 Tmr Svc B 4 191 11 Led B 2 36 2 MB/TCPAcpt B 2 218 7 TCP/IP Stack B 2 596 1 RS4852 S 2 474 6 CC S 2 463 8 Qsec S 2 191 9 RS4850 S 2 474 4 RS4851 S 2 474 5 ~~~


FreeRTOS 10.0.0 Problem: vTaskList is truncating information about the calling task

Posted by rtel on December 11, 2017

Going to try and replicate this now.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Webinar

"OTA Update Security and Reliability" webinar presented by TI and AWS. Register here.


Careers

FreeRTOS and other embedded software careers at AWS.


Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner