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

Enable priority inheritance for RTT mutexes (gnulinux) #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented Oct 24, 2019

By default pthread mutexes used in the implementation of the gnulinux target do not have priority inheritance enabled. Priority inheritance is one way to prevent priorty inversion issues in real-time systems. So this is a pretty important feature for Orocos RTT, too.

The behavior of setting the attribute PTHREAD_PRIO_INHERIT is well explained in the POSIX documentation for pthread_mutexattr_setprotocol:

The protocol attribute defines the protocol to be followed in utilizing mutexes. The value of protocol may be one of:

PTHREAD_PRIO_INHERIT
PTHREAD_PRIO_NONE
PTHREAD_PRIO_PROTECT

which are defined in the <pthread.h> header. The default value of the attribute shall be PTHREAD_PRIO_NONE.

When a thread owns a mutex with the PTHREAD_PRIO_NONE protocol attribute, its priority and scheduling shall not be affected by its mutex ownership.

When a thread is blocking higher priority threads because of owning one or more non-robust mutexes with the PTHREAD_PRIO_INHERIT protocol attribute, it shall execute at the higher of its priority or the priority of the highest priority thread waiting on any of the non-robust mutexes owned by this thread and initialized with this protocol.

[...]

Xenomai mutex services enforce a priority inheritance protocol in order to solve priority inversions (https://xenomai.org/documentation/xenomai-2.6/html/api/group__mutex.html).

I am not sure whether priority inheritance could be enabled for pthread mutexes on macOS X, too. But before #310 RTT used the Boost.Thread mutex implementation to implement timed mutexes. With #310 Boost.Thread usage has been dropped, but because waiting on a mutex held by another thread is actually implemented by waiting on a condition variable, priority inheritance cannot easily be applied.

@meyerj meyerj added this to the 2.10 milestone Oct 24, 2019
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.

1 participant