mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Posix: Free the allocated memory after deleting a task or ending the scheduler (#181)
* Posix: Free Idle task resources after ending the scheduler In case of using Posix simulator and ending the scheduler, it does not free the resources allocated by the idle task. This causes the memory checkers (Valgrind, Address Sanitizers, ..) to complain. * Posix: Free the condition variable memory in the correct place In case of deleting a task from another task, the deletion happens immediately and the thread is canceled but the memory allocated by the task condition variable is not freed. This causes the memory checkers (Valgrind, Address sanitizers, ..) to complain. * Posix: End Timer thread and free its resources after ending the scheduler
This commit is contained in:
parent
2225bb5620
commit
baeb5af9a4
10
portable/ThirdParty/GCC/Posix/port.c
vendored
10
portable/ThirdParty/GCC/Posix/port.c
vendored
|
@ -62,6 +62,7 @@
|
|||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "utils/wait_for_event.h"
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -197,6 +198,13 @@ sigset_t xSignals;
|
|||
sigwait( &xSignals, &iSignal );
|
||||
}
|
||||
|
||||
/* Cancel the Idle task and free its resources */
|
||||
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 );
|
||||
|
||||
|
@ -405,6 +413,7 @@ Thread_t *pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
|
|||
*/
|
||||
pthread_cancel( pxThreadToCancel->pthread );
|
||||
pthread_join( pxThreadToCancel->pthread, NULL );
|
||||
event_delete( pxThreadToCancel->ev );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -444,7 +453,6 @@ BaseType_t uxSavedCriticalNesting;
|
|||
prvResumeThread( pxThreadToResume );
|
||||
if ( pxThreadToSuspend->xDying )
|
||||
{
|
||||
event_delete(pxThreadToSuspend->ev);
|
||||
pthread_exit( NULL );
|
||||
}
|
||||
prvSuspendSelf( pxThreadToSuspend );
|
||||
|
|
Loading…
Reference in a new issue