cFE unit-tests have thread deallocation tests and found out that thread was being woken up from timeout-queue when it is being deleted and also more subtle issues on deleted threads. To avoid races, and to cleanup the thread (except the actual system resource) use critical-section and delete it from timeout queue and scheduling policy module. This is what @Others and I've debugged recently.
It would be good if sl_thd_alloc is also atomic w.r.t sl library, so that there will not be races in backend allocations when users dynamically allocate more threads. Added that.
removed assert when there is nothing to schedule from sl_mod_schedule.
also added basic unit-tests for sl_thd_free. (idle thread runs after all test threads are deleted in the system.)
Reference: PR #262
Intent for your PR
Choose one (Mandatory):
[ ] This PR is for a code-review and is intended to get feedback, but not to be pulled yet.
[x] This PR is mature, and ready to be integrated into the repo.
Reviewers (Mandatory):
@gparmer @Others
Code Quality
As part of this pull request, I've considered the following:
Summary of this Pull Request (PR)
sl_thd_alloc
is also atomic w.r.t sl library, so that there will not be races in backend allocations when users dynamically allocate more threads. Added that.sl_mod_schedule
.sl_thd_free
. (idle thread runs after all test threads are deleted in the system.)Reference: PR #262
Intent for your PR
Choose one (Mandatory):
Reviewers (Mandatory):
@gparmer @Others
Code Quality
As part of this pull request, I've considered the following:
Style:
Code Craftsmanship:
Testing
I've tested the code using the following test programs (provide list here):
sl_thd_free
.