# Priority inheritance

**URL:** <https://www.ruby-forum.com/t/priority-inheritance/153187>\
**Category:** Ruby\
**Created:** [November 13, 2008, 2:30am UTC](https://www.ruby-forum.com/t/priority-inheritance/153187 "2008-11-13T02:30:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Cunha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@Daniel\_Cunha](https://www.ruby-forum.com/u/Daniel_Cunha)\
**Post date:** [November 13, 2008, 2:30am UTC](https://www.ruby-forum.com/t/priority-inheritance/153187/1 "2008-11-13T02:30:22Z")

</div>

Hi,

I would like to now if there is a library that implements priority  
inheritance in Ruby.

I now that some people thing that you are already in trouble if you need  
to use this approach. But I really need to.

A little about priority inheritance:

"Imagine a system with two processes running, one at high priority and  
the other at a much lower priority. These processes share resources  
which are protected by locks. At some point, the low-priority process  
manages to run and obtains a lock for one of those resources. If the  
high-priority process then attempts to obtain the same lock, it will  
have to wait. Essentially, the low-priority process has trumped the  
high-priority process, at least for as long as it holds the contended  
lock.

Now imagine a third process, one which uses a lot of processor time, and  
which has a priority between the other two. If that process starts to  
crank, it will push the low-priority process out of the CPU  
indefinitely. As a result, the third process can keep the  
highest-priority process out of the CPU indefinitely.

This situation, called “priority inversion,” tends to be followed by  
system failure, upset users, and unemployed engineers. There are a  
number of approaches to avoiding priority inversion, including lockless  
designs, carefully thought-out locking scenarios, and a technique known  
as priority inheritance. The priority inheritance method is simple in  
concept: when a process holds a lock, it should run at (at least) the  
priority of the highest-priority process waiting for the lock. When a  
lock is taken by a low-priority process, the priority of that process  
might need to be boosted until the lock is released." [1]

More references about PI:

[1] [Priority inheritance in the kernel [LWN.net]](http://lwn.net/Articles/178253/)

[http://kernelnewbies.org/Linux\_2\_6\_18](http://kernelnewbies.org/Linux_2_6_18)

> **[\[200+\] Linux Wallpapers | Wallpapers.com](https://wallpapers.com/linux)**
>
> Linux 1080P, 2K, 4K, 8K HD Wallpapers ✓ Must-View Free Linux Wallpaper Images - Don't Miss ✓ 100% Free to Use ✓ Personalise for all Screen & Devices.

[http://www.xenomai.org/documentation/trunk/html/api/group\_\_synch.html](http://www.xenomai.org/documentation/trunk/html/api/group__synch.html)

Thanks in advance,

Daniel Cunha
