-
Notifications
You must be signed in to change notification settings - Fork 2k
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
core: implement core_mutex_priority_inheritance #17040
core: implement core_mutex_priority_inheritance #17040
Conversation
Is #7445 a solution?? |
Yes, only needs a rebase and adaption to the changes to core/mutex that got in since 2018. This is alternative regarding the test case used there, but IMO this PR is preferable due to its compatibility with all boards (no Makefile.ci). It does not test for priority inversion in case of core/msg - but IMO it is sensible to separate the tests, since they cover different synchronisation mechanisms. |
Where are we at here? |
The infrastructure to change the priority of a running thread is now in place. So half way there. (Or actually even more, extending the mutex to make use of it is relatively simple.) I think I can PR this today. |
ed0f703
to
33b2845
Compare
I added the corresponding code in a new commit to this PR. It kind of makes sense to me have the fix in the corresponding test application (or rather it's cleanup) in the same PR. |
33b2845
to
6009a55
Compare
Note that decoupling priority inheritance for mutex and msg makes sense, as there is a trade-off. In a use case that needs to mitigate priority inversion for shared bus accesses is not automatically affected by priority inversion via msg. The issue of priority inversion can occur due to hardware limitations (e.g. a low prio and a high prio task needing to talk to hardware on the single I2C bus available) and for some use cases cannot be avoided. I have to admit that I didn't spent much time thinking about it, but since msg is not linked to shared hardware resource, I believe that priority inversion could be solved by carefully designing the software so that it cannot occur. In any case, #7445 implements priority inheritance only for We can still add priority inheritance for msg later on, if that is indeed needed. |
C++ does not like the mutex initialization macro 😕 |
Ah, yes. Named initializers ( |
The use of I wonder if we should just provide a tiny stdio implementation and make that a default module when |
286f025
to
1be5cd1
Compare
I changed the At least this forced me to re-run the test and notice that I had to increase the stack sizes due to #18162 being merged. |
Please squash! |
1be5cd1
to
0aafdf8
Compare
All green and test is still passing |
0aafdf8
to
3446752
Compare
Uncrustify should now also hopefully be happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 |
thx :) |
Hmm just adding the |
Contribution description
This implements
core_mutex_mitigate_priority_inversion
, a module that employs the textbook solution of priority inheritance to mitigate priority inversion.In addition, the corresponding test was cleaned up and automated:
Makefile.ci
can be dropped by usingfmt
over stdio and reducing stack sizesTesting procedure
should build, flash and run. It should fail without
core_mutex_mitigate_priority_inversion
(comment out line in the test'sMakefile
), but pass with if it is used.Issues/PRs references
None