1. priority inversion)
Because multi-process resources are shared, the process with the highest priority is blocked by the low-priority process. Instead, the process with the medium priority is executed before the high-priority process, leading to system crash. This is the so-called priority inversion ).
2. Cause
In fact, priority inversion is blocked when a high-priority task (assumed as a) accesses resources occupied by a low-priority task (assumed as C. at this time, when there are tasks with a higher priority than (c) that occupy resources, and tasks with a lower priority than (B) of the blocked task (, A task that occupies a resource is suspended (the occupied resource is still occupied). Because the priority of a task that occupies the resource is very low, it may be suspended by another task all the time. the resources it occupies cannot be released, which causes task a to be unable to execute. tasks with lower priority can be executed.
Therefore, a solution is to increase the priority of a resource-consuming task, so that it can be executed normally, and then release the resource so that task a can obtain the resource and execute it normally.
3. solution (Priority Inheritance/priority ceiling)
Currently, there are many ways to reverse the priority. There are two commonly used methods: Priority Inheritance and priority ceilings ).
. priority Inheritance
Priority Inheritance increases the priority of a low-priority task to the highest-priority task waiting for its resources. when a high-priority task is blocked due to waiting for resources, the priority of the resource owner is automatically increased.
B. priority ceiling (Priority ceilings)
the priority ceiling refers to raising the priority of a task applying for a resource to the highest priority of all tasks that may access the resource. (this priority is called the priority ceiling of the resource.)
Differences between A and B:
Priority Inheritance, only when a task with a low priority of a resource is blocked will the priority of the task with a higher priority be raised, and the priority ceiling is increased whether or not the task is blocked.