Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug related to memory leakage when calling vTaskEndScheduler #15

Closed
wants to merge 7 commits into from

Conversation

KKoovalsky
Copy link

This pull requests addresses the issue #14. A new function has been added which cleans up resources. To gracefully stop the scheduler a function vTaskEndScheduler must be called within task code and then vPortCleanup must be called after the call to vTaskStartScheduler from the main thread.

This function must be invoked from main thread and it destroys mutex
which guards the list of threads to be joined.
The threads which are running when the scheduler is being stopped are
since now canceled and joined. The thread which called vTaskEndScheduler
must be treated in a special way because it mustn't cancel itself.
pthread_t of this thread is saved and then by calling
vPortJoinSchedulerEndCaller from main thread cancels the thread and
joins it.
On pthread_exit pthread_t is saved on a list and then on cleaning up the
application (by calling vPortJoinSchedulerEndCaller) those threads are
joined. This commit also implements handling the list of pthreads' IDs.
@michaelbecker
Copy link
Owner

Some changes manually merged into master. Did not include code that joined threads, pthread detach handles this better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants