FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2017 Threads]
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 */
}
~~~
Not sure. Looking at it now I would say its probably not necessary. It
might be a hang over from before uxDeletedTasksWaitingCleanUp was
introduced.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.