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
pull/190/head
Reda Maher 4 years ago committed by GitHub
parent 2225bb5620
commit baeb5af9a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save