Skip to content

Commit 190fc03

Browse files
fix(freertos-smp): Fixes for xTaskIncrementTick and prvEvaluateCoreForYield
1 parent 76a9b26 commit 190fc03

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

event_groups.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,10 @@
884884
static BaseType_t prvUnlockEventGroupForTasks( EventGroup_t * pxEventBits )
885885
{
886886
BaseType_t xReturn = pdFALSE;
887+
BaseType_t xCoreID = portGET_CORE_ID();
887888

888889
/* Release the previously held task spinlock */
889-
portRELEASE_SPINLOCK( portGET_CORE_ID(), &( pxEventBits->xTaskSpinlock ) );
890+
portRELEASE_SPINLOCK( xCoreID, &( pxEventBits->xTaskSpinlock ) );
890891

891892
/* Re-enable preemption */
892893
vTaskPreemptionEnable( NULL );
@@ -899,7 +900,7 @@
899900
/* Return true as the task was preempted */
900901
xReturn = pdTRUE;
901902
}
902-
else if( xTaskHigherPriorityTasksReady() == pdTRUE )
903+
else if( xTaskHigherPriorityTasksReady( xCoreID ) == pdTRUE )
903904
{
904905
/* Higher priority tasks are ready to run */
905906
taskYIELD_WITHIN_API();

include/task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3890,7 +3890,7 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
38903890
* yield decisions when unlocking.
38913891
*/
38923892
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
3893-
BaseType_t xTaskHigherPriorityTasksReady( void );
3893+
BaseType_t xTaskHigherPriorityTasksReady( BaseType_t xCoreID );
38943894
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
38953895

38963896
#if ( portUSING_MPU_WRAPPERS == 1 )

tasks.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
15001500
if( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U )
15011501
{
15021502
/* Core can yield immediately */
1503-
if( xCorePriority < *pxLowestImmediatePriority )
1503+
if( xCorePriority <= *pxLowestImmediatePriority )
15041504
{
15051505
*pxLowestImmediatePriority = xCorePriority;
15061506
*pxImmediateYieldCore = xCoreID;
@@ -1510,7 +1510,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
15101510
{
15111511
/* Core could yield if preemption were enabled */
15121512
if( ( pxPendingYieldCore != NULL ) && ( pxLowestPendingPriority != NULL ) &&
1513-
( xCorePriority < *pxLowestPendingPriority ) )
1513+
( xCorePriority <= *pxLowestPendingPriority ) )
15141514
{
15151515
*pxLowestPendingPriority = xCorePriority;
15161516
*pxPendingYieldCore = xCoreID;
@@ -1520,7 +1520,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
15201520
/* Preemption disable not configured, can yield immediately */
15211521
( void ) pxPendingYieldCore;
15221522
( void ) pxLowestPendingPriority;
1523-
if( xCorePriority < *pxLowestImmediatePriority )
1523+
if( xCorePriority <= *pxLowestImmediatePriority )
15241524
{
15251525
*pxLowestImmediatePriority = xCorePriority;
15261526
*pxImmediateYieldCore = xCoreID;
@@ -5356,7 +5356,7 @@ BaseType_t xTaskIncrementTick( void )
53565356
#if ( configNUMBER_OF_CORES == 1 )
53575357
{
53585358
/* For single core the core ID is always 0. */
5359-
if( xYieldPendings[ 0 ] != pdFALSE )
5359+
if( xYieldPendings[ 0 ] != pdFALSE || xTaskHigherPriorityTasksReady( 0 ) != pdFALSE )
53605360
{
53615361
xSwitchRequired = pdTRUE;
53625362
}
@@ -5376,7 +5376,7 @@ BaseType_t xTaskIncrementTick( void )
53765376
if( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U )
53775377
#endif
53785378
{
5379-
if( xYieldPendings[ xCoreID ] != pdFALSE )
5379+
if( xYieldPendings[ xCoreID ] != pdFALSE || xTaskHigherPriorityTasksReady( xCoreID ) != pdFALSE )
53805380
{
53815381
if( xCoreID == xCurrentCoreID )
53825382
{
@@ -8050,10 +8050,9 @@ static void prvResetNextTaskUnblockTime( void )
80508050

80518051
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
80528052

8053-
BaseType_t xTaskHigherPriorityTasksReady( void )
8053+
BaseType_t xTaskHigherPriorityTasksReady( BaseType_t xCoreID )
80548054
{
80558055
BaseType_t xReturn = pdFALSE;
8056-
BaseType_t xCoreID = portGET_CORE_ID();
80578056

80588057
/* Only check if scheduler is running and not suspended */
80598058
if( ( xSchedulerRunning != pdFALSE ) && ( uxSchedulerSuspended == pdFALSE ) )

0 commit comments

Comments
 (0)