From 294569e495515e238dc890a8b4613d01260d1f06 Mon Sep 17 00:00:00 2001 From: Chen YM Date: Mon, 19 Aug 2024 13:04:33 +0800 Subject: [PATCH] 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 Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- tasks.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tasks.c b/tasks.c index 3382954b8..cb3c190b9 100644 --- a/tasks.c +++ b/tasks.c @@ -4698,10 +4698,6 @@ BaseType_t xTaskIncrementTick( void ) TickType_t xItemValue; BaseType_t xSwitchRequired = pdFALSE; - #if ( configUSE_PREEMPTION == 1 ) && ( configNUMBER_OF_CORES > 1 ) - BaseType_t xYieldRequiredForCore[ configNUMBER_OF_CORES ] = { pdFALSE }; - #endif /* #if ( configUSE_PREEMPTION == 1 ) && ( configNUMBER_OF_CORES > 1 ) */ - traceENTER_xTaskIncrementTick(); /* Called by the portable layer each time a tick interrupt occurs. @@ -4853,7 +4849,7 @@ BaseType_t xTaskIncrementTick( void ) { if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCBs[ xCoreID ]->uxPriority ] ) ) > 1U ) { - xYieldRequiredForCore[ xCoreID ] = pdTRUE; + xYieldPendings[ xCoreID ] = pdTRUE; } else { @@ -4905,7 +4901,7 @@ BaseType_t xTaskIncrementTick( void ) if( pxCurrentTCBs[ xCoreID ]->xPreemptionDisable == pdFALSE ) #endif { - if( ( xYieldRequiredForCore[ xCoreID ] != pdFALSE ) || ( xYieldPendings[ xCoreID ] != pdFALSE ) ) + if( xYieldPendings[ xCoreID ] != pdFALSE ) { if( xCoreID == xCurrentCoreID ) {