Вы находитесь на странице: 1из 3

BLOCK 1 UNIT 4

DEADLOCKS
Q1. What is deadlock?
Ans: A deadlock is a situation where a group of processes is permanently blocked as a
result of each process having acquired a set of resources needed for its completion and
having to wait for the release of the remaining resources held by other thus making it
impossible for any of the deadlocked processes to proceed.
Q. What a!e the t"o t#$es o% !eso&!ces?
Ans: The two types of resources are given below:
(a) '!e(e)$ti*e !eso&!ces+ This resource can be taken away from the process with no ill
effects. Memory is an eample of a pre!emptable resource.
(b) No,('!ee)$ti*e -eso&!ces+ This resource cannot be taken away from the process
without causing ill effect. "orm eample# $% resources are not preemptable at an
arbitrary moment.
Q.. What a!e the cha!acte!istics o% a deadlock o! %o&! ,ecessa!# co,ditio,s %o!
deadlock?
Ans: The four necessary conditions that must hold simultaneously for a deadlock to
occur are eplained below:
/i0 1&t&al E2cl&sio, Co,ditio,
The resources involved are non!shareable. At least one resource must be held in a non!
shareable mode# which is only one process at a time claims eclusive control of the
resource. &f another process requests that resource# the requesting process must be
delayed until the resource has been released.
/ii0 3old a,d Wait Co,ditio,
&n this condition# a requesting process already holds resources and waiting for the
requested resources. A process# holding a resource allocated to it waits for an additional
resources(s) that is'are currently being held by other processes.
/iii0 No,('!ee)$ti*e Co,ditio,
(esources already allocated to a process cannot be preempted. (esources cannot be
removed forcibly from the processes. After completion# they will be released voluntarily
by the process holding it.
/i*0 Ci!c&la! Wait Co,ditio,
The processes in the system form a circular list or chain where each process in the list is
waiting for a resource held by the net process in the list.
Q4. E2$lai, the deadlock $!e*e,tio, )echa,is).
Ans: )avender gives algorithm for deadlock prevention. The )avender*s algorithm for
deadlock prevention is eplained below:
/a0 Eli)i,atio, o% 1&t&al E2cl&sio, Co,ditio,
The mutual eclusion condition must hold for non!shareable resources. That is# several
processes cannot simultaneously share a single resource. This condition is difficult to
eliminate because some resources such as the tap drive and printer# are inherently non!
shareable. +ote that shareable resources like read!only file do not require mutually
eclusive access and thus cannot be involved in deadlock.
/40 Eli)i,atio, o% 3old a,d Wait Co,ditio,
There are two possibilities for the elimination of hold and wait condition. The first
alternative is that a process request be granted all the resources it needs at once# prior to
eecution. The second alternative is to disallow a process from requesting resources
whenever it has previously allocated resources. This strategy requires that all the
resources a process will need must be requested at once.
/c0 Eli)i,atio, o% No('!ee)$tio, Co,ditio,
The non!preemption condition can be alleviated by forcing a process waiting for a
resource that cannot immediately be allocated# to relinquish all of its currently held
resources# so that other processes may use them to finish their needs.
/d0 Eli)i,atio, o% Ci!c&la! Wait Co,ditio,
The last condition# the circular wait# can be denied by imposing a total ordering on all of
the resource types and than forcing all processes to request the resources in order of
increasing or decreasing. This strategy imposes a total ordering of all resources types# and
requires that each process request resources in a numerical order of enumeration.
Q5. E2$lai, ho" to a*oid deadlock?
Ans: The most famous deadlock avoidance algorithm from %i,kstra is the -anker*s
Algorithm. The -anker algorithm is based on the banking system# which never allocates
its available cash in such a manner that it can no longer satisfy the needs of all its
customers. The -anker*s algorithm is based on the banking system# which never allocates
its available cash in such a manner that it can no longer satisfy the needs of all its
customers. The following are the features that are to be considered for avoidance of the
deadlock per the -anker*s Algorithms:
(.) /ach process declares maimum number of resources of each type that it may need.
(0) 1eep the system in a safe state in which we can allocate resources to each process in
some order and avoid deadlock.
(2) $heck for the safe state by finding a safe sequence: 34.# 4054n6 where resources
that 4i needs can be satisfied by available resources plus resources held by 4, where ,
3 i.
(7) (esource allocation graph algorithm uses claim edges to check for safe state.
Q6. What a!e the li)itatio,s o% the Ba,ke!7s al8o!ith)?
Ans: The limitations of the -anker*s algorithm are given below:
(.) &t is time consuming to eecute on the operation of every resource.
(0) &f the claim information is not accurate# system resources may be underutili8ed.
(2) Another difficulty can occur when a system is heavily loaded.
(7) +ew processes arriving may cause a problem.
(9) A resource becoming unavailable can result in an unsafe state.
Q9. E2$lai, deadlock detectio,.
Ans: %etection of deadlocks is the most practical policy# which being both liberal and
cost efficient# most operating system deploys. To detect a deadlock# we must go about in
a recursive manner and simulate the most favored eecution of each unblocked process.
(i) An unblocked process may require all the needed resources and will eecute.
(ii) &t will then release all the required resources and remain dormant thereafter.
(iii) The now released resources may wake up some previously blocked process.
(iv)$ontinue the above steps as long as possible.
(v) &f any blocked processes remain# they are deadlocked.
Q:. What a!e the )ethods o% !eco*e!# %!o) deadlock?
Ans: The methods of recovery from deadlock are eplained below:
/a0 -eco*e!# %!o) $!ocess te!)i,atio,
&n this approach# we terminate deadlocked processes in a systematic way taking into
account their priorities. The moment# enough processes are terminated to recover from
deadlock# we stop the process termination.
/40 -eco*e!# 4# check $oi,ti,8 a,d !oll4ack.
$heck pointing is saving enough state of a process so that the process can be restarted at
the point in the computation where the checkpoint was taken. &f a deadlock is detected#
one or more processes are restarted from their last checkpoint. (estarting a process from
a checkpoint is called rollback. &t is done with the epectation that the resource requests
will not interleave again to produce deadlock.

Вам также может понравиться