Fix #470, Binary sem task delete issues #472
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the contribution
Corrects issue when a task waiting on a binary semaphore is deleted, it left the mutex in a locked state preventing other tasks from using the mutex.
This has 3 parts:
OS_BinSemTake()
and then attempts to use the semaphore after this. (without the rest of this change, it fails).pthread_cond_wait()
call. This ensures that the mutex is unlocked as part of the cleanup, so other tasks may continue using the semaphore. This is the main fix as it directly addresses the root cause of the issue, which is that the mutex was left in a locked state.Fixes #470
Fixes nasa/cFE#701
Testing performed
Build and run all unit tests.
Confirm that including only the unit test change (item 1 above) reliably reproduces the failure. In this mode, bin-sem-test will get stuck when attempting to give the semaphore after task deletion.
Confirm that the bin sem changes (items 2 and 3 above) correct the issue. Note each one taken individually will avoid deadlock in a different way. Item 3 (timed mutex) alone will cause the subsequent calls to return
OS_SEM_FAILURE
rather than deadlock, so shutdown will continue and the test exits with a failed status rather than pending forever.Sanity check CFE operation and CTRL+C handling - all works OK.
Expected behavior changes
Binary semaphores after task deletion continue to work as expected and are usable by other tasks.
System(s) tested on
Ubuntu 20.04
Additional context
Add any other context about the contribution here.
Third party code
If included, identify any third party code and provide text file of license
Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.