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 ]    [ Sitemap ]    [ ]




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

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

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


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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