From 4aa6e04c6eabbada4b85ad5f6fe378b2178aea90 Mon Sep 17 00:00:00 2001 From: Jeff Tenney Date: Tue, 23 Jun 2020 10:40:07 -0700 Subject: [PATCH] Protect xPendedTicks with critical section Function xTaskIncrementTick() increments xPendedTicks when the scheduler is disabled. That function typically executes inside the tick ISR. So code in xTaskCatchUpTicks() must mask interrupts when modifying xPendedTicks. --- tasks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks.c b/tasks.c index 1046791a4..735b79974 100644 --- a/tasks.c +++ b/tasks.c @@ -2636,7 +2636,9 @@ BaseType_t xYieldOccurred; /* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occurring when the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */ vTaskSuspendAll(); + taskENTER_CRITICAL(); xPendedTicks += xTicksToCatchUp; + taskEXIT_CRITICAL(); xYieldOccurred = xTaskResumeAll(); return xYieldOccurred;