freertos: Idle task shouldn't hold xTaskQueueMutex while calling TLS destructors
If the callbacks use any blocking call (ie printf), this can otherwise trigger a deadlock.
This commit is contained in:
parent
2ccc2ec5ee
commit
3234064b6a
1 changed files with 14 additions and 14 deletions
|
@ -3577,17 +3577,16 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
|
||||
/* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
|
||||
too often in the idle task. */
|
||||
taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||
while(uxTasksDeleted > ( UBaseType_t ) 0U )
|
||||
{
|
||||
TCB_t *pxTCB = NULL;
|
||||
taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||
{
|
||||
xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
|
||||
}
|
||||
|
||||
if( xListIsEmpty == pdFALSE )
|
||||
{
|
||||
TCB_t *pxTCB;
|
||||
|
||||
{
|
||||
pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
|
||||
/* We only want to kill tasks that ran on this core because e.g. _xt_coproc_release needs to
|
||||
|
@ -3598,12 +3597,15 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
--uxTasksDeleted;
|
||||
} else {
|
||||
/* Need to wait until the idle task on the other processor kills that task first. */
|
||||
taskEXIT_CRITICAL(&xTaskQueueMutex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL(&xTaskQueueMutex);
|
||||
|
||||
if (pxTCB != NULL) {
|
||||
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
|
||||
{
|
||||
int x;
|
||||
for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ )
|
||||
{
|
||||
|
@ -3612,7 +3614,6 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
pxTCB->pvThreadLocalStoragePointersDelCallback[ x ](x, pxTCB->pvThreadLocalStoragePointers[ x ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
prvDeleteTCB( pxTCB );
|
||||
}
|
||||
|
@ -3621,7 +3622,6 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL(&xTaskQueueMutex);
|
||||
}
|
||||
#endif /* vTaskDelete */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue