diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index eaff6d96ea..0392a6e3c5 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -1251,6 +1251,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending[xPortGetCoreID()] ); portYIELD_WITHIN_API(); } + else if ( portNUM_PROCESSORS > 1 && pxTCB == pxCurrentTCB[ !xPortGetCoreID() ] ) + { + /* if task is running on the other CPU, force a yield on that CPU to take it off */ + vPortYieldOtherCore( !xPortGetCoreID() ); + } else { /* Reset the next expected unblock time in case it referred to diff --git a/components/freertos/test/test_preemption.c b/components/freertos/test/test_preemption.c index 09dbcc003a..83ab49bf43 100644 --- a/components/freertos/test/test_preemption.c +++ b/components/freertos/test/test_preemption.c @@ -66,8 +66,8 @@ TEST_CASE("Yield from lower priority task, same CPU", "[freertos]") printf("Yielding from lower priority task took %u cycles\n", delta); TEST_ASSERT(delta < 10000); - vQueueDelete(queue); vTaskDelete(sender_task); + vQueueDelete(queue); } }