Skip to content

Commit e9310aa

Browse files
fix(freertos-smp): Fix yielding decisions based on preemption state of task
1 parent 2ac2c14 commit e9310aa

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

tasks.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,23 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
10851085
#endif
10861086
{
10871087
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1088+
{
10881089
if( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U )
1089-
#endif
1090+
{
1091+
xLowestPriorityToPreempt = xCurrentCoreTaskPriority;
1092+
xLowestPriorityCore = xCoreID;
1093+
}
1094+
else
1095+
{
1096+
xYieldPendings[ xCoreID ] = pdTRUE;
1097+
}
1098+
}
1099+
#else
10901100
{
10911101
xLowestPriorityToPreempt = xCurrentCoreTaskPriority;
10921102
xLowestPriorityCore = xCoreID;
10931103
}
1104+
#endif
10941105
}
10951106
}
10961107
else
@@ -1391,12 +1402,23 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
13911402
( xYieldPendings[ uxCore ] == pdFALSE ) )
13921403
{
13931404
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1405+
{
13941406
if( pxCurrentTCBs[ uxCore ]->uxPreemptionDisable == 0U )
1395-
#endif
1407+
{
1408+
xLowestPriority = xTaskPriority;
1409+
xLowestPriorityCore = ( BaseType_t ) uxCore;
1410+
}
1411+
else
1412+
{
1413+
xYieldPendings[ uxCore ] = pdTRUE;
1414+
}
1415+
}
1416+
#else
13961417
{
13971418
xLowestPriority = xTaskPriority;
13981419
xLowestPriorityCore = ( BaseType_t ) uxCore;
13991420
}
1421+
#endif
14001422
}
14011423
}
14021424
}
@@ -3053,12 +3075,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
30533075
/* Setting the priority of a running task down means
30543076
* there may now be another task of higher priority that
30553077
* is ready to execute. */
3056-
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
3057-
if( pxTCB->uxPreemptionDisable == 0U )
3058-
#endif
3059-
{
3060-
xYieldRequired = pdTRUE;
3061-
}
3078+
xYieldRequired = pdTRUE;
30623079
}
30633080
else
30643081
{

0 commit comments

Comments
 (0)