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

Support using a priority inheritance protocol #3356

Closed
wants to merge 2 commits into from

Conversation

jdknight
Copy link

@jdknight jdknight commented Mar 8, 2025

Provides initial support for utilizing a priority inheritance protocol for mutexes if supported by the threading library. Developers can opt to build with SPDLOG_PRIORITY_INHERITANCE enabled to help avoid priority inversion scenarios.


The following change set is being proposed to help the spdlog framework to be better equip for (near) real-time applications. I was asked about a suggested logging framework to use for a C++ application and recommended spdlog; however, I was told by others that they could not use it since the risk of priority inversion scenarios with the use of the standard library's mutex implementations. This spawned this change set by adding support for priority inheritance for environments that support such a capability. At this time, this only brings support for Linux gcc/clang environments (as least, that is all that has been tested with).

If such a change is not desired in the logging framework, no worries.

jdknight added 2 commits March 8, 2025 13:43
Provides initial support for utilizing a priority inheritance protocol
for mutexes if supported by the threading library. Developers can opt to
build with `SPDLOG_PRIORITY_INHERITANCE` enabled to help avoid
priority inversion scenarios.

Signed-off-by: James Knight <[email protected]>
Adds additional jobs to test with `SPDLOG_PRIORITY_INHERITANCE` enabled.

Signed-off-by: James Knight <[email protected]>
@jdknight jdknight force-pushed the priority-inheritance branch from 47165c1 to 31a3322 Compare March 8, 2025 18:44
@gabime
Copy link
Owner

gabime commented Mar 8, 2025

Thanks. Indeed, I am not sure if I want to support this. In any case the change can be less intrusive. Just define a new kind of mutex (see null_mutex.h for example) and let users pass it as template param when creating the sinks. This would cover most of use cases, and for the rest (the queue and registry), a using mutex=pi_mutex could be used with ifdef. So I think there is no need for a wrapper class with mutex in it.

@jdknight
Copy link
Author

jdknight commented Mar 8, 2025

K k. Thanks for the feedback; will close.

@jdknight jdknight closed this Mar 8, 2025
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.

2 participants