Академический Документы
Профессиональный Документы
Культура Документы
Operating Systems
Assignment
Submitted by:
Sankalp Jain
(1RV08CS096)
8.1 List three examples of deadlocks that are not related to a computer-system
environment.
Answer :
8.2 Is it possible to have a deadlock involving only one single process? Explain your answer.
Answer:
8.3 People have said that proper spooling would eliminate deadlocks. Certainly, it
eliminates from contention card readers, plotters, printers, and so on. It is even possible to
spool tapes (called staging them), which would leave the resources of CPU time, memory,
and disk space. Is it possible to have a deadlock involving these resources? If it is, how
could
such a deadlock occur? If it is not, why not? What deadlock scheme would seem best to
eliminate these deadlocks (if any are possible), or what condition is violated (if they are not
possible)?
Answer:
It is possible to still have a deadlock. Process P1 holds memory pages that are required by
process P2 , while P2 is holding the CPU that is required by P1.The best way to eliminate these
types of deadlock is to use preemption.
Answer:
8.5 Suppose that a system is in an unsafe state. Show that it is possible for the processes to
complete their execution without entering a deadlock state.
Answer:
8.6 In a real computer system, neither the resources available nor the demands of
processes for resources are consistent over long periods (months). Resources break or are
replaced, new processes come and go, new resources are bought and added to the system. If
deadlock is controlled by the banker’s algorithm, which of the following changes can be
made safely (without introducing the possibility of deadlock), and under what
circumstances?
a.
Increase Available (new resources added).
b.
Decrease Available (resource permanently removed from system).
c.
Increase Max for one process (the process needs more resources than allowed, it may want
more).
d.
Decrease Max for one process (the process decides it does not need that many resources).
e.
Increase the number of processes.
f.
Decrease the number of processes.
Answer:
a.
Anytime
b.
Only if Max demand of each process does not exceed total number of available resources, and
the system remains in a safe state.
c.
Same as (b)
d.
Anytime
e.
Anytime
f.
Anytime
8.7 Prove that the safety algorithm presented in Section 7.5.3 requires an order of m × n2
operations.
Answer:
Step 2 may be executed n +(n -1)+(n -2)+... +3+2+1= n × (n + 1)/2 times. In each iteration, m
resource types must be examined. Therefore the algorithm requires m × n × (n +1)/2steps.
8.8 Consider a system consisting of four resources of the same type that are shared by three
processes, each of which needs at most two resources. Show that the system is deadlock-
free.
Answer:
Suppose the system is deadlocked. This implies that each process is holding one resource and is
waiting for one more. Since there are three processes and four resources, one process must be
able to obtain two resources. This process requires no more resources and therefore it will return
its resources when done.