From 04c5f51ad819f59e7f2a6a514c1360f493c4026c Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Thu, 22 Oct 2020 16:48:51 -0700 Subject: [PATCH] Fix missed yield in xTaskResumeFromISR If a higher priority task than the currently running task was resumed using xTaskResumeFromISR and the user chose to ignore the return value of xTaskResumeFromISR to initiate a context switch using portYIELD_FROM_ISR, we were not doing the context switch on the next run of the scheduler. This change fixes this by marking a yield as pending to ensure that the context switch is performed on the next run of the scheduler. Signed-off-by: Gaurav Aggarwal --- tasks.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks.c b/tasks.c index 94b3e1f86..62ab95a30 100644 --- a/tasks.c +++ b/tasks.c @@ -1949,6 +1949,11 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { xYieldRequired = pdTRUE; + + /* Mark that a yield is pending in case the user is not + * using the return value to initiate a context switch + * from the ISR using portYIELD_FROM_ISR. */ + xYieldPending = pdTRUE; } else {