Analyze several real questions about deadlock

 The following four points are the content of the deadlock section in 408. The test frequency is basically one question per year. Although more than half of the questions are about the unsafe sequence of the banker's algorithm, several of them combine The following concepts, if we do not analyze the relationship between these concepts in advance now. Maybe someone was fooled randomly in the examination room.

  1. Deadlock concept
  2. Deadlock prevention
  3. Deadlock avoidance
  4. Deadlock detection and contact

 

2015 real questions

The four necessary conditions for deadlock are: mutually exclusive resources; inalienability; request and hold; and circular wait chain. As long as one of the necessary conditions for deadlock is destroyed, deadlock will definitely not occur. This is also called deadlock prevention. The memorization formula is to prevent death due to eating and broadcasting diseases.

S1 in the question will limit the order in which users apply for resources, which destroys the cyclic waiting chain and belongs to deadlock prevention. The main question is about deadlock avoidance, so the first one is definitely wrong.

The second article says that deadlock avoidance requires total resource information, no problem, this is what the banker's algorithm needs. Deadlock detection and release does not care how you allocate resources, but provides a means of detection and release, so the third point is also correct. But it stands to reason that the resource allocation map requires knowing how many resources the process needs to apply for. If you don't know how many resources the process needs, how can you detect it? However, after excluding the first item in this question, you can only choose B.

                                                                 2016 real questions

 

This question is awesome. First of all, the P4 process only needs one resource. It does not meet the request and retention conditions, so it does not participate in deadlock. Exclude option D, and then there is no need to discuss P4. This is the key to solving this question. . Then the loop waiting condition deadlock requires at least 2 processes, excluding option A.

The rest can be exhausted:

P1 occupies R1 , P2 occupies R3, and P3 does not need R2. There is no deadlock at this time. P1 occupies R1, P2 occupies R2, and P3 must occupy R3 to deadlock, three deadlocks.

P1 occupies R2 , P2 occupies R3, and P3 occupies R1, three deadlocks.

P1 occupies nothing , and P2 and P3 will not deadlock.

The only choice is C.

                                                           A concept question after class 

 

Option B jitter is eliminated first.

A necessary condition for deadlock is non-deprivation, and the question talks about depriving one process of resources from other blocked processes, then deadlock will definitely not occur, and option A is excluded.

Rollback is a method to relieve deadlock, provided that a deadlock has already occurred, excluding option C.

You can only choose D. It’s not that I wanted to choose, I was forced to choose.

                                                                   After-school questions

It is also the detection and prevention of deadlock that integrates the content of deadlock prevention and four necessary conditions. 

I personally don't agree with option C. The answer is that C must be deadlocked. I don't think so.

Unless the graph is not a resource allocation graph, or does not have a cycle, it obviously does because it has no topologically sorted sequence. From the definition of a cycle: a path in which the first vertex and the last vertex are the same is called a loop or a ring, which is no problem. But during the exam, I will follow the answer method. The picture above should not belong to the situation in the question, but I don’t know why it doesn’t belong.

Guess you like

Origin blog.csdn.net/weixin_74059671/article/details/133376959