mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
freertos: fix dual core issue
This commit fixes: 1. xTaskGetCurrentTaskHandle may return wrong TCB when current task switch to a different core 2. Idle task may have problem when it terminate the task in both core
This commit is contained in:
parent
a760eb3980
commit
2cffaf9cc8
@ -3496,26 +3496,27 @@ static void prvCheckTasksWaitingTermination( void )
|
|||||||
|
|
||||||
/* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
|
/* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
|
||||||
too often in the idle task. */
|
too often in the idle task. */
|
||||||
|
taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||||
while( uxTasksDeleted > ( UBaseType_t ) 0U )
|
while( uxTasksDeleted > ( UBaseType_t ) 0U )
|
||||||
{
|
{
|
||||||
taskENTER_CRITICAL(&xTaskQueueMutex);
|
//taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||||
{
|
{
|
||||||
xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
|
xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL(&xTaskQueueMutex);
|
//taskEXIT_CRITICAL(&xTaskQueueMutex);
|
||||||
|
|
||||||
if( xListIsEmpty == pdFALSE )
|
if( xListIsEmpty == pdFALSE )
|
||||||
{
|
{
|
||||||
TCB_t *pxTCB;
|
TCB_t *pxTCB;
|
||||||
|
|
||||||
taskENTER_CRITICAL(&xTaskQueueMutex);
|
//taskENTER_CRITICAL(&xTaskQueueMutex);
|
||||||
{
|
{
|
||||||
pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
|
pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
|
||||||
( void ) uxListRemove( &( pxTCB->xGenericListItem ) );
|
( void ) uxListRemove( &( pxTCB->xGenericListItem ) );
|
||||||
--uxCurrentNumberOfTasks;
|
--uxCurrentNumberOfTasks;
|
||||||
--uxTasksDeleted;
|
--uxTasksDeleted;
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL(&xTaskQueueMutex);
|
//taskEXIT_CRITICAL(&xTaskQueueMutex);
|
||||||
|
|
||||||
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
|
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
|
||||||
{
|
{
|
||||||
@ -3535,7 +3536,8 @@ static void prvCheckTasksWaitingTermination( void )
|
|||||||
{
|
{
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taskEXIT_CRITICAL(&xTaskQueueMutex);
|
||||||
}
|
}
|
||||||
#endif /* vTaskDelete */
|
#endif /* vTaskDelete */
|
||||||
}
|
}
|
||||||
@ -3806,10 +3808,12 @@ TCB_t *pxTCB;
|
|||||||
{
|
{
|
||||||
TaskHandle_t xReturn;
|
TaskHandle_t xReturn;
|
||||||
|
|
||||||
|
vPortCPUAcquireMutex(&xTaskQueueMutex);
|
||||||
/* A critical section is not required as this is not called from
|
/* A critical section is not required as this is not called from
|
||||||
an interrupt and the current TCB will always be the same for any
|
an interrupt and the current TCB will always be the same for any
|
||||||
individual execution thread. */
|
individual execution thread. */
|
||||||
xReturn = pxCurrentTCB[ xPortGetCoreID() ];
|
xReturn = pxCurrentTCB[ xPortGetCoreID() ];
|
||||||
|
vPortCPUReleaseMutex(&xTaskQueueMutex);
|
||||||
|
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user