From 78c8bbde0e7cbcca40ba3ed97ea1fd2b34e255be Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Tue, 7 May 2024 20:47:14 +0530 Subject: [PATCH] Update xPortRunning before resuming first task (#1049) The variable `xPortRunning` is now updated before starting the first task. It fixes the following issue - https://forums.freertos.org/t/possible-bug-in-the-way-prvtimertask-thread-function-is-started-in-win32-port/19959/ Signed-off-by: Gaurav Aggarwal --- portable/MSVC-MingW/port.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index d489746f5..66c9a53ea 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -353,12 +353,12 @@ BaseType_t xPortStartScheduler( void ) pxThreadState = ( ThreadState_t * ) *( ( size_t * ) pxCurrentTCB ); ulCriticalNesting = portNO_CRITICAL_NESTING; - /* Start the first task. */ - ResumeThread( pxThreadState->pvThread ); - /* The scheduler is now running. */ xPortRunning = pdTRUE; + /* Start the first task. */ + ResumeThread( pxThreadState->pvThread ); + /* Handle all simulated interrupts - including yield requests and * simulated ticks. */ prvProcessSimulatedInterrupts();