fix(freertos-smp): Fix yielding decisions based on preemption state of task

This commit is contained in:
Sudeep Mohanty 2025-08-05 13:31:35 +02:00
parent 60bca5e8b2
commit e3d92dd5fd

31
tasks.c
View file

@ -1085,12 +1085,23 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
#endif #endif
{ {
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 ) #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
{
if( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U ) if( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U )
#endif
{ {
xLowestPriorityToPreempt = xCurrentCoreTaskPriority; xLowestPriorityToPreempt = xCurrentCoreTaskPriority;
xLowestPriorityCore = xCoreID; xLowestPriorityCore = xCoreID;
} }
else
{
xYieldPendings[ xCoreID ] = pdTRUE;
}
}
#else
{
xLowestPriorityToPreempt = xCurrentCoreTaskPriority;
xLowestPriorityCore = xCoreID;
}
#endif
} }
} }
else else
@ -1391,12 +1402,23 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
( xYieldPendings[ uxCore ] == pdFALSE ) ) ( xYieldPendings[ uxCore ] == pdFALSE ) )
{ {
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 ) #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
{
if( pxCurrentTCBs[ uxCore ]->uxPreemptionDisable == 0U ) if( pxCurrentTCBs[ uxCore ]->uxPreemptionDisable == 0U )
#endif
{ {
xLowestPriority = xTaskPriority; xLowestPriority = xTaskPriority;
xLowestPriorityCore = ( BaseType_t ) uxCore; xLowestPriorityCore = ( BaseType_t ) uxCore;
} }
else
{
xYieldPendings[ uxCore ] = pdTRUE;
}
}
#else
{
xLowestPriority = xTaskPriority;
xLowestPriorityCore = ( BaseType_t ) uxCore;
}
#endif
} }
} }
} }
@ -3053,13 +3075,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
/* Setting the priority of a running task down means /* Setting the priority of a running task down means
* there may now be another task of higher priority that * there may now be another task of higher priority that
* is ready to execute. */ * is ready to execute. */
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
if( pxTCB->uxPreemptionDisable == 0U )
#endif
{
xYieldRequired = pdTRUE; xYieldRequired = pdTRUE;
} }
}
else else
{ {
/* Setting the priority of any other task down does not /* Setting the priority of any other task down does not