From e98ea9ef667de8407f1d9ea56ee0e928d04e1e71 Mon Sep 17 00:00:00 2001 From: Reda Maher Date: Mon, 28 Sep 2020 01:37:07 +0200 Subject: [PATCH] Posix: End Timer thread and free its resources after ending the scheduler --- portable/ThirdParty/GCC/Posix/port.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/portable/ThirdParty/GCC/Posix/port.c b/portable/ThirdParty/GCC/Posix/port.c index 45bb6f0f5..7d7b5d887 100644 --- a/portable/ThirdParty/GCC/Posix/port.c +++ b/portable/ThirdParty/GCC/Posix/port.c @@ -62,6 +62,7 @@ /* Scheduler includes. */ #include "FreeRTOS.h" #include "task.h" +#include "timers.h" #include "utils/wait_for_event.h" /*-----------------------------------------------------------*/ @@ -178,7 +179,6 @@ portBASE_TYPE xPortStartScheduler( void ) { int iSignal; sigset_t xSignals; -TaskHandle_t pxIdleThread; hMainThread = pthread_self(); @@ -186,8 +186,6 @@ TaskHandle_t pxIdleThread; Interrupts are disabled here already. */ prvSetupTimerInterrupt(); - pxIdleThread = xTaskGetIdleTaskHandle(); - /* Start the first task. */ vPortStartFirstTask(); @@ -201,7 +199,11 @@ TaskHandle_t pxIdleThread; } /* Cancel the Idle task and free its resources */ - vPortCancelThread(pxIdleThread); + vPortCancelThread( xTaskGetIdleTaskHandle() ); +#if ( configUSE_TIMERS == 1 ) + /* Cancel the Timer task and free its resources */ + vPortCancelThread( xTimerGetTimerDaemonTaskHandle() ); +#endif /* configUSE_TIMERS */ /* Restore original signal mask. */ (void)pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );