Skip to contentSkip to conversation

Priority inheritance?

DISCUSSION Stanislav Meduna 2 participants 2 messages Oct 29, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

strictly speaking not a linux-rt specific questions but I think that the folks here have the needed experience and knowledge:
what is the relation of
pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
and scheduler class used for a particular thread? Does the priority inheritance work across all threads in the system or is it limited to one scheduling class?

Specifically: my application has some SCHED_RR threads with fixed priorities and realtime needs and a few that are quite low-prio, actually have the SCHED_OTHER semantics and I don't want them to count against the time spent in RT (keyword: throttler).

I need to occasionally queue data from from the RT-ones to the low-prio ones, so for short periods of time I need to lock a mutex. With it comes the question of priority inversion.

Can I leave the low-prio threads at SCHED_OTHER and rely on the PTHREAD_PRIO_INHERIT to boost their priority in case they were preempted with the lock held and the RT-thread needs to lock it too, or do they have to be SCHED_RR too?

Thanks

Signature · 1 line
                                    Stano
#1 lore raw
Quoted 4 lines · Stanislav Meduna

Can I leave the low-prio threads at SCHED_OTHER and rely on the PTHREAD_PRIO_INHERIT to boost their priority in case they were preempted with the lock held and the RT-thread needs to lock it too

That's how priority inheritance is defined. In case of contention the lock owner inherits the scheduling class and the priority of the (higher class/priority) contender.

Thanks,

tglx