]> granicus.if.org Git - esp-idf/commitdiff
freertos: Preempt other CPU when deleting a task running on it
authorAngus Gratton <angus@espressif.com>
Wed, 10 May 2017 07:23:33 +0000 (17:23 +1000)
committerAngus Gratton <gus@projectgus.com>
Wed, 10 May 2017 07:23:33 +0000 (17:23 +1000)
Includes related fix to preemption unit tests (delete a queue after deleting the task blocked on it.)

components/freertos/tasks.c
components/freertos/test/test_preemption.c

index eaff6d96ea03d0407e6168bec308c938e864b6e5..0392a6e3c5bed2485a32608d9c60ac3a752ec68f 100644 (file)
@@ -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
index 09dbcc003a9e0d249f2fdbff2e8fd42ccb59b138..83ab49bf433a0121c4bf429282c81c0e8723a6ba 100644 (file)
@@ -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);
     }
 }