4. WHATIS DEADLOCK?
o An example from US Kansas law:
o “When two trains approach each other at a
crossing, both shall come to a full stop and
neither shall start up again until the other
has gone.”
44
6. Deadlock in Operating System
A DEADLOCK is a situation in which two process is sharing the same
resource and preventing each other from accessing the resource, resulting
in case where both process is not working.
Example
6
7. Four Conditions Of deadlock
Mutual Exclusion
At least on resource of the system is in non-sharable mode, that is only one process may use it at
any given time. Thus if any other process requests for the resource, then that process will have to
wait until the current process which is using the resource release it.
Hold and Wait
A process must exist which is already holding a resource and also waiting to grab one or more
resources which are currently being held by another processes.
No preemption
Resources can not be preempted, that is, a resource can be released only by the process that is
currently holding it, voluntarily. Thus, release of the process is out of control and a process may
hold a resource forever.
Circular Wait
There must exist a set of processes; such as, p0,p1,p2….pN; which are waiting for resources which
are in hold by other processes. The process that p0 need is in hold by p1, the process that p1 need
is in hold by p2 and so on. It is a dead-end.
7
8. DEADLOCK PREVENTION
Eliminate one (or more) of:
mutual exclusion
hold and wait
no preemption (i.e. have preemption)
circular wait
8
10. Banker’s Algorithm
Deadlock avoidance algorithm.
It’s less efficient than resource allocation graph
algorithm.
But it is applicable to resource allocation
system with multiple instances of each resource
type.
1
0
11. In this algorithm there are
following matrices:
1.N number of processes
2. m number of resources.
.Calculate safe sequence is if
possible .
1
1
15. Wait For Graph
Create a wait for graph by removing the
resource type nodes from a resource allocation
graph
Deadlock exists if and only if the wait-for graph
contains a cycle.
1
5