Quality RTOS & Embedded Software

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


Loading

Confused about prvCheckTasksWaitingTermination() function

Posted by ctc8631 on May 9, 2017

Hello, I'm new freeRTOS learner, I try to read v9.0 source code about task.c, and in idle task, it will call prvCheckTasksWaitingTermination()

I'm confused why in this function, it already check there is need deleded task or not by while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U ), Why still need to use xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination ); to check again,and Why it will use vTaskSuspendAll(); and xTaskResumeAll(); to protect listLIST_IS_EMPTY() I found the xTaskResumeAll(), it really takes times

Is there any reason? thanks =) ~~~ static void prvCheckTasksWaitingTermination( void ) {

/** THIS FUNCTION IS CALLED FROM THE RTOS IDLE TASK **/

#if ( INCLUDE_vTaskDelete == 1 )
{
	BaseType_t xListIsEmpty;

	/* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
	too often in the idle task. */
	while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U )
	{
		vTaskSuspendAll();
		{
			xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
		}
		( void ) xTaskResumeAll();

		if( xListIsEmpty == pdFALSE )
		{
			TCB_t *pxTCB;

			taskENTER_CRITICAL();
			{
				pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
				( void ) uxListRemove( &( pxTCB->xStateListItem ) );
				--uxCurrentNumberOfTasks;
				--uxDeletedTasksWaitingCleanUp;
			}
			taskEXIT_CRITICAL();

			prvDeleteTCB( pxTCB );
		}
		else
		{
			mtCOVERAGE_TEST_MARKER();
		}
	}
}
#endif /* INCLUDE_vTaskDelete */

} ~~~


Confused about prvCheckTasksWaitingTermination() function

Posted by rtel on May 9, 2017

Not sure. Looking at it now I would say its probably not necessary. It might be a hang over from before uxDeletedTasksWaitingCleanUp was introduced.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



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

Renesas

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