Skip to content

Commit

Permalink
Optimize xTaskIncrementTick for configNUMBER_OF_CORES > 1
Browse files Browse the repository at this point in the history
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 <cymb103u@cs.ccu.edu.tw>
  • Loading branch information
cymizer committed Aug 15, 2024
1 parent 40dbccf commit 50d9f70
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -4857,7 +4857,7 @@ BaseType_t xTaskIncrementTick( void )
}
else
{
mtCOVERAGE_TEST_MARKER();
xYieldRequiredForCore[ xCoreID ] = pdFALSE;
}
}
}
Expand Down Expand Up @@ -4905,7 +4905,11 @@ BaseType_t xTaskIncrementTick( void )
if( pxCurrentTCBs[ xCoreID ]->xPreemptionDisable == pdFALSE )
#endif
{
if( ( xYieldRequiredForCore[ xCoreID ] != pdFALSE ) || ( xYieldPendings[ xCoreID ] != pdFALSE ) )
#if ( configUSE_TIME_SLICING == 1 )
if( ( xYieldRequiredForCore[ xCoreID ] != pdFALSE ) || ( xYieldPendings[ xCoreID ] != pdFALSE ) )
#else
if( xYieldPendings[ xCoreID ] != pdFALSE )
#endif /* #if ( configUSE_TIME_SLICING == 1 ) */
{
if( xCoreID == xCurrentCoreID )
{
Expand Down

0 comments on commit 50d9f70

Please sign in to comment.