hw_deadlock

IC411 Homework, Chapter 6
Spring 2017 84 points total
Name ____________________________
Learning Objective
Concurrency (CON) -- Explain the principles of mutual exclusion and synchronization of running processes. Describe and
be able to implement strategies for detection, avoidance, and prevention of process deadlock and starvation. Be able to
solve problems in a multi-threaded programming environment. (supports CS/IT Student Outcome (i))
(12) 1. List and define the four conditions that must be present for deadlock to be possible:
(12) 2. For the following resource requests and allocations, draw a single Resource Allocation Graph.
P1 holds a unit of Rc and a unit of Ra; P1 requests a unit of Rb
P2 holds a unit of Rb; P2 requests a unit of Ra
P3 holds a unit of Ra; P3 requests a unit of Rc
(4) 3. In the preceding example. assuming the necessary preconditions for deadlock (from question 6.1) exist,
are these processes deadlocked? Explain why or why not.
(10) 4. Consider the following snapshot of processes and resources, as evaluated by the Banker’s Algorithm.
From a deadlock avoidance perspective, is this state a “safe” state? If not, explain why not. If so, identify
which process or processes may be selected next by the OS to run to completion. Show all your work for full
credit.
(5) 5. In Figure 6-1 of the text, the resources are returned in the reverse order of acquisition. Would giving
them back in the other order be just as good?
(5) 6. Is it possible that a resource deadlock involves multiple units of one type and a single unit of another? If
so, give an example.
(5) 7. In order to control traffic, a network router, A, periodically sends a message to its neighbor, B, telling it
to increase or decrease the number of packets that it can handle. At some point in time, router A is flooded with
traffic and Sends B a message telling it to cease sending traffic. It does this by specifying the number of bytes B
may send (A's "window size") is 0. As traffic decreases, A sends a new message, telling B to restart
transmission. It does this by increasing the window size from 0 to a positive number. That message is lost. As
described, neither side will ever transmit. What type of deadlock is this? Justify your answer.
(10) 8. Consider the following state of a system with four processes and five kinds of resources. Using the
deadlock detection algorithm, determine where there is a deadlock in the system, and identify the deadlocked
processes.
Explain how the system can recover from the deadlock using:
(2) a) pre-emption
(2) b) rollback
(2) c) killing processes
(5) 9. Suppose that in Figure 6-6 of the text, Cij + Rij > Ej for some i and j. What implications does this have
for the system?
(5) 10. A system has two processes and three identical resources. Each process needs a maximum of two such
resources. Is deadlock possible? Explain your answer.
(5) 11. Chapter 6, Question 38 of the text (p.469 in 4th edition).