Skip to content

Commit 294569e

Browse files
cymizeraggarg
andauthored
Optimize xTaskIncrementTick for configNUMBER_OF_CORES > 1 (#1118)
The original implementation only initializes the first variable. After executing xTaskIncrementTick, the schedule might not behave as expected. When configUSE_PREEMPTION == 1 & configUSE_TIME_SLICING == 1, replace setting xYieldRequiredForCore[ xCoreID ] with setting xYieldPendings[ xCoreID ]. And when configUSE_PREEMPTION == 1, simplify the check condition to only check xYieldPendings[ xCoreID ]. Signed-off-by: cymzier <[email protected]> Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
1 parent a936c10 commit 294569e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

tasks.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,10 +4698,6 @@ BaseType_t xTaskIncrementTick( void )
46984698
TickType_t xItemValue;
46994699
BaseType_t xSwitchRequired = pdFALSE;
47004700

4701-
#if ( configUSE_PREEMPTION == 1 ) && ( configNUMBER_OF_CORES > 1 )
4702-
BaseType_t xYieldRequiredForCore[ configNUMBER_OF_CORES ] = { pdFALSE };
4703-
#endif /* #if ( configUSE_PREEMPTION == 1 ) && ( configNUMBER_OF_CORES > 1 ) */
4704-
47054701
traceENTER_xTaskIncrementTick();
47064702

47074703
/* Called by the portable layer each time a tick interrupt occurs.
@@ -4853,7 +4849,7 @@ BaseType_t xTaskIncrementTick( void )
48534849
{
48544850
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCBs[ xCoreID ]->uxPriority ] ) ) > 1U )
48554851
{
4856-
xYieldRequiredForCore[ xCoreID ] = pdTRUE;
4852+
xYieldPendings[ xCoreID ] = pdTRUE;
48574853
}
48584854
else
48594855
{
@@ -4905,7 +4901,7 @@ BaseType_t xTaskIncrementTick( void )
49054901
if( pxCurrentTCBs[ xCoreID ]->xPreemptionDisable == pdFALSE )
49064902
#endif
49074903
{
4908-
if( ( xYieldRequiredForCore[ xCoreID ] != pdFALSE ) || ( xYieldPendings[ xCoreID ] != pdFALSE ) )
4904+
if( xYieldPendings[ xCoreID ] != pdFALSE )
49094905
{
49104906
if( xCoreID == xCurrentCoreID )
49114907
{

0 commit comments

Comments
 (0)