Multi-process multithreading priority understanding-priority reversal "go"

Source: Internet
Author: User

This article was reproduced from: http://blog.csdn.net/yusiguyuan/article/details/14161061

1. Priority reversal (inversion)
Because of multi-process shared resources, the process with the highest priority is blocked by a low-priority process, which causes the process with the middle priority to execute before the high-priority process, causing the system to crash. This is called priority reversal (inversion).

2. Cause
In fact, the priority reversal is blocked when the task of the high-priority (assuming a) accesses a resource that is owned by a low-precedence task (assumed to be C). And at this point there is a task with a priority higher than the resource-occupying task (c) and less than the priority of the blocked task (a) (assuming B), The task of owning a resource is suspended (the resource in possession is still in it), because the task that occupies the resource has a low priority, so it may have been suspended by another task. And the resources that it occupies have been unable to be released, so that task A has not been able to execute. The task that is lower than its priority can be executed.

Therefore, one solution is to increase the priority of the resource-occupying task, let it execute normally, and then release the resources so that task A can get the resources properly.

3. Solution (Priority inheritance/priority ceiling)

There are many ways to resolve priority reversals at this time. There are 2 kinds of methods commonly used: one is called priority inheritance, and the other is called priority ceilings.

A. Precedence inheritance (priority inheritance)
Priority inheritance is the prioritization of a low-priority task to the highest-priority task that waits for the resources it occupies. When a high-priority task is blocked by waiting for a resource, the priority of the resource's owner is automatically promoted.

B. Priority ceilings (ceilings)
The priority ceiling is the priority of the task that requests a resource to the highest priority task in all tasks that might access the resource. (This priority is called the resource's priority ceiling)

The difference between A and B:

Priority inheritance increases the priority of the resource-occupying task only when the low-priority task of the resource is blocked, and the priority ceiling, whether or not it is blocked, is promoted.

Multi-process multithreading priority understanding-priority reversal "go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.