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 */
}
~~~