Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The concept of deadlock and the cause of deadlock

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

The definition of deadlock

In multi-program piecemeal, because of the concurrent implementation of multiple processes, the application rate of piecemeal capital is improved and the ability of piecemeal disposal is improved. However, the concurrent implementation of multiple processes also brings a new achievement-deadlock. The so-called deadlock refers to a deadlock formed by multiple processes competing for capital (waiting for each other). If there is no external force, these processes will not be able to move forward.

Here are some examples to illustrate the deadlock scene.

First, let's take a look at an example in our life. There is a bridge over a river. The bridge deck is so narrow that it can only accommodate one car. If two vehicles drive on the bridge from both ends of the bridge, there will be the following conflict. At this time, the car on the right occupies the right section of the bridge deck, and if you want to cross the bridge, you have to wait for the car on the left to give up the left section of the bridge deck; the car on the left side occupies the left section of the bridge deck. To cross the bridge, you have to wait for the car on the right to give up the right section of the bridge deck. At this point, if your cars on both sides can only drive forward, neither car can cross the bridge.

A similar situation exists in bits and pieces of computers. For example, as long as there is only one printer and one output equipment in the bits and pieces of a computer, process P1 is occupying the output equipment, and at the same time, it makes a plea to use the printer, but at this time the printer is occupied by process P2, and before P2 releases the printer, it is also proposed to use the output equipment that is being occupied by P1. Such two processes wait endlessly for each other, and neither can be carried out continuously, at this time the two processes fall into a deadlock.

The cause of deadlock 1) the competition of piecemeal capital

There is a lack of capital in bits and pieces to meet the needs of many processes, so that the process will fall into a stalemate due to grabbing capital, such as tape drives, printers and so on. As long as the competition for deprivation of capital from Fucheng can occur, the competition for disposable capital will not cause a deadlock.

2) process-driven sequence is legal

In the process of operation, the order of pleading and releasing capital is out of order, and it will lead to deadlock. For example, concurrent processes P1 and P2 insist on capital R1 and R2, while process P1 requests capital R2, and process P2 requests capital R1, both of them will be choked because the required capital is occupied.

Improper use of signals can also form a deadlock. The process waits for each other to hear from each other, and the consequences will make it impossible for these processes to continue to move forward. For example, process An is waiting for the message from process B, and process B is waiting for the message from process A. it can be seen that process An and B are not competing for unified capital, but waiting for each other's capital to incur a deadlock.

3) the necessary premise of deadlock.

The occurrence of deadlock must be satisfied with the following four premises at the same time, as long as any of the premises is not true, deadlock will not occur.

Mutually exclusive premise: the process requests to stop the exclusive control of the allocated capital (such as the printer), that is, a certain capital is occupied by only one process over a period of time. At this time, if there is another process to beg the capital, the pleading process can only wait.

Non-preemptive premise: the capital obtained by the process cannot be forcibly taken by other processes before the end of its use, that is, it can only be released by the process itself (only automatically).

Supplication and adherence to the premise: the process has insisted on at most one capital, but put forward a new capital request, which has been occupied by other processes, and the pleading process is choked up, but insists on the capital I have acquired.

Reincarnation waiting premise: there is a reincarnation waiting chain of process capital in which the capital obtained by each process is begged by the next process in the chain at the same time. That is, there is a waiting process that aggregates {Pl, P2,..., pn}, in which the waiting capital such as Pi is occupied by P (iSuppli 1), and the waiting capital of Pn is occupied by P0, as shown in figure 2-15.

From a straight point of view, the premise of reincarnation waiting seems to be the same as the definition of deadlock, but in fact it is not. According to the deadlock boundary, the premise of forming a waiting ring is more stringent, which requires that the capital of Pi waiting must be satisfied by P (item1), while the premise of reincarnation waiting has no such restriction. For example, there are two input devices in bits and pieces, P0 occupies one, competition occupies the other, and K does not belong to aggregation {0,1,., n}.

Pn is waiting for an input device, which can be obtained from P0 or from competition. Thus, although Pn, P0, and other processes constitute the reincarnation waiting circle, the competition is not in the circle, and if the competition releases the input equipment, it can break the reincarnation waiting, as shown in figure 2-16. Therefore, reincarnation waiting is only a prerequisite for deadlock.

The reason why the capital allocation chart is circular and piecemeal and different must be deadlock is that the number of similar capital is greater than 1. However, if only one capital is needed for each type of capital source in bits and pieces, the circle in the capital allocation map will lead to a sufficient prerequisite for piecemeal deadlock.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report