Operating System Chapter 6 Homework

Multiple choice

  1. Which statement about deadlock is correct?
    A. A single process may cause deadlock
    B. Deadlock can occur between any process
    C. Deadlock only occurs between unrelated processes
    D. At least two of the processes involved in the deadlock occupy resources
    E. All processes participating in the deadlock occupy resources

D. There are at least two processes involved in the deadlock, set p1, p2, p1 to occupy the resource r1 and wait for the resource r2, and p2 to occupy the resource r2 and wait for the resource r1;
E. All processes participating in the deadlock are waiting for the resource;

Subjective questions

  1. There are 5 processes P1, P2, P3, P4, P5 sharing three types of resources A (17), B (5), C (20), the system status at T0 is as follows:
    Insert picture description here
    May I ask

(1) Whether it is a safe state at T0, if it is safe, please give a safe series.

(2) At time T0, P2:Request(0,3,4), can it be allocated and why?

(3) On the basis of (2), P4: Request(2,0,1), can it be allocated and why?

(4) On the basis of (3), P1: Request(0,2,0), can it be allocated and why?

Knowledge supplement:
Available (available remaining resources) = total resources-Allocation (allocated resources);
listed in the list (MANA): Max [maximum demand], Allocation [allocated resources], Need [demand (missing) resources], Available【Remaining resources available】; After
Request(x,x,x), the value in the corresponding Need is transferred to Allocation;

Answer:
(1) The security security series is {p4,p5,p2,p1,p3} (hint: when actually doing the question, add two columns, one column is the number of resources still needed and the other column is the number of remaining available resources, using the banker algorithm Analyze one by one)
(2) Cannot be allocated because: the number of available resources is only 2 3 3, which is not enough to allocate
(3) Can be allocated because: the number of requested resources does not exceed the number of remaining available resources, and the allocation does not meet the set maximum demand Conflict, there are security series {p4,p5,p2,p1,p3} that will not deadlock after the allocation is completed
(4) Cannot be allocated because: although the number of requested resources does not exceed the number of remaining available resources, and the allocation does not match the set The maximum demand conflicts, but there is no more security series after the allocation, which will lead to subsequent deadlock
.
Detailed explanation:
Insert picture description here
first compare request and need, request<=need is established, otherwise
request and available are not established , request<=available then If it is true, otherwise it is not true.
Insert picture description here
First compare request and need. Request<=need is true, otherwise it is not true.
Request and available are compared. Request<=available is true, otherwise it is not true.
If both are true, modify the previous value.
available= available-request
allocation=allocation+request
need=need-request
Insert picture description here
Insert picture description here

  1. Try to simplify the resource allocation diagram in the figure below, and use the deadlock theory to give a conclusion
    Insert picture description here

Knowledge Supplement (P184):
Simplify:
① Find a non-isolated process node with only allocation edges, remove the allocation edges, and turn it into an isolated node;
② Assign the corresponding resource to a process waiting for the resource, which means The application side of a certain process becomes the allocation side;
③ Repeat;
Insert picture description here

Answer:
Simplify first, as shown in the figure below (marking the order), and
finally there is a looped path on the right part, and there is only one resource of each type,
so P1 and P4 will cause deadlocks on R3 and R4 resources (Of course, because P3 cannot get R3, P3 will also be affected and enter the deadlock)
Insert picture description here

Guess you like

Origin blog.csdn.net/Jessieeeeeee/article/details/109235550