Unit 2 Answers

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Operating systems

Unit 2

1) A)Define a Deadlock.Determine the four necessary conditions for a deadlock to occur.


(6 mark)

It is a situation where each of the computer process waits for a resource which is being assigned to
some another process. In this situation, none of the process gets executed since the resource it needs, is
held by some other process which is also waiting for some other resource to be released.
1) Mutual Exclusion:
A resource can only be shared in mutually exclusive manner. It implies, if two process cannot
use the same resource at the same time.
2) Hold and Wait:
A process waits for some resources while holding another resource at the same time.
3) No preemption:
The process which once scheduled will be executed till the completion. No other process can be
scheduled by the scheduler meanwhile.
4) Circular Wait:
All the processes must be waiting for the resources in a cyclic manner so that the last process is
waiting for the resource which is being held by the first process.

B) Brief about Deadlock Ignorance method. (2 mark)

Stick your head in the sand and pretend there is no problem at all, this method of solving any problem is
called Ostrich Algorithm

In General :

 System failure
 Compiler error
 programming bugs
 hardware crashes
 Wait & Try

2) A)What is a deadlock? (2 mark)


It is a situation where each of the computer process waits for a resource which is being assigned to
some another process. In this situation, none of the process gets executed since the resource it needs, is
held by some other process which is also waiting for some other resource to be released.

B)How deadlocks can be detected in single instance and multiple instance resources? Explain
with an example. (6 mark)

Single Instance of Each Resource Type:

Scanned with CamScanner


Scanned with CamScanner
3)A)Formulate the differences between Deadlock and Starvation. (4 marks)

Scanned with CamScanner


B)Briefly explain about Deadlock Characterization. (4 mark)
Necessary conditions:
1) Mutual Exclusion:
A resource can only be shared in mutually exclusive manner. It implies, if two process cannot
use the same resource at the same time.
2) Hold and Wait:
A process waits for some resources while holding another resource at the same time.
3) No preemption:
The process which once scheduled will be executed till the completion. No other process can be
scheduled by the scheduler meanwhile.
4) Circular Wait:
All the processes must be waiting for the resources in a cyclic manner so that the last process is
waiting for the resource which is being held by the first process.
Resource allocation graph:
 This graph consists of a set of vertices V and a set of edges E.
 The set of vertices V is partitioned into 2 different types of nodes.
 P = {P1, P2….Pn}, the set consisting of all the active processes in the system.
 R= {R1, R2….Rm}, the set consisting of all resource types in the system.
 A directed edge from process Pi to resource type Rj is denoted by Pi ->Rj. It signifies that process
Pi has requested an instance of resource type Rj and is currently waiting for that resource.
 A directed edge Pi ->Rj is called a requested edge.
 A directed edge from resource type Rj to process Pi is denoted by Rj ->Pi, it signifies that an
instance of resource type Rj has been allocated to process Pi.
 A directed edge Rj->Pi is called an assignment edge.
 We represent each process Pi as a circle, each resource type Rj as a rectangle.
 Since resource type Rj may have more than one instance. We represent each such instance as a
dot within the rectangle.
 A request edge points to only the rectangle Rj.
 An assignment edge must also designate one of the dots in the rectangle.

Scanned with CamScanner


 When process Pi requests an instance of resource type Rj, a request edge is inserted in the
resource allocation graph.
 When this request can be fulfilled, the request edge is instantaneously transformed to an
assignment edge.
 When the process no longer needs access to the resource, it releases the resource, as a result, the
assignment edge is deleted.

4.Discuss in detail about various deadlock handling strategies.


Deadlock is a situation where a process or a set of processes is blocked, waiting for some
other resource that is held by some other waiting process. It is an undesirable state of the
system. The following are the four conditions that must hold simultaneously for a
deadlock to occur.
1. Mutual Exclusion – A resource can be used by only one process at a time. If
another process requests for that resource then the requesting process must be
delayed until the resource has been released.
2. Hold and wait – Some processes must be holding some resources in the non-
shareable mode and at the same time must be waiting to acquire some more
resources, which are currently held by other processes in the non-shareable
mode.
3. No pre-emption – Resources granted to a process can be released back to the
system only as a result of voluntary action of that process after the process has
completed its task.
4. Circular wait – Deadlocked processes are involved in a circular chain such that
each process holds one or more resources being requested by the next process in
the chain.
Methods of handling deadlocks: There are four approaches to dealing with deadlocks.
1. Deadlock Prevention
2. Deadlock avoidance (Banker's Algorithm)
3. Deadlock detection & recovery
4. Deadlock Ignorance (Ostrich Method)
These are explained below.
1. Deadlock Prevention: The strategy of deadlock prevention is to design the system in
such a way that the possibility of deadlock is excluded. The indirect methods prevent the
occurrence of one of three necessary conditions of deadlock i.e., mutual exclusion, no pre-
emption, and hold and wait. The direct method prevents the occurrence of circular
wait. Prevention techniques – Mutual exclusion – are supported by the OS. Hold and

Scanned with CamScanner


Wait – the condition can be prevented by requiring that a process requests all its required
resources at one time and blocking the process until all of its requests can be granted at the
same time simultaneously. But this prevention does not yield good results because:
 long waiting time required
 inefficient use of allocated resource
 A process may not know all the required resources in advance
No pre-emption – techniques for ‘no pre-emption are’
 If a process that is holding some resource, requests another resource that can not
be immediately allocated to it, all resources currently being held are released and
if necessary, request again together with the additional resource.
 If a process requests a resource that is currently held by another process, the OS
may pre-empt the second process and require it to release its resources. This
works only if both processes do not have the same priority.
Circular wait One way to ensure that this condition never holds is to impose a total
ordering of all resource types and to require that each process requests resources in
increasing order of enumeration, i.e., if a process has been allocated resources of type R,
then it may subsequently request only those resources of types following R in ordering.
2. Deadlock Avoidance: The deadlock avoidance Algorithm works by proactively looking
for potential deadlock situations before they occur. It does this by tracking the resource
usage of each process and identifying conflicts that could potentially lead to a deadlock. If
a potential deadlock is identified, the algorithm will take steps to resolve the conflict, such
as rolling back one of the processes or pre-emptively allocating resources to other
processes. The Deadlock Avoidance Algorithm is designed to minimize the chances of a
deadlock occurring, although it cannot guarantee that a deadlock will never occur. This
approach allows the three necessary conditions of deadlock but makes judicious choices to
assure that the deadlock point is never reached. It allows more concurrency than avoidance
detection A decision is made dynamically whether the current resource allocation request
will, if granted, potentially lead to deadlock. It requires knowledge of future process
requests. Two techniques to avoid deadlock :
1. Process initiation denial
2. Resource allocation denial
Advantages of deadlock avoidance techniques:
 Not necessary to pre-empt and rollback processes
 Less restrictive than deadlock prevention
Disadvantages :
 Future resource requirements must be known in advance
 Processes can be blocked for long periods
 Exists a fixed number of resources for allocation
Banker’s Algorithm:
The Banker’s Algorithm is based on the concept of resource allocation graphs. A resource
allocation graph is a directed graph where each node represents a process, and each edge
represents a resource. The state of the system is represented by the current allocation of
resources between processes. For example, if the system has three processes, each of
which is using two resources, the resource allocation graph would look like this:
Processes A, B, and C would be the nodes, and the resources they are using would be the
edges connecting them. The Banker’s Algorithm works by analyzing the state of the
system and determining if it is in a safe state or at risk of entering a deadlock.
To determine if a system is in a safe state, the Banker’s Algorithm uses two matrices: the
available matrix and the need matrix. The available matrix contains the amount of each
resource currently available. The need matrix contains the amount of each resource
required by each process.
Scanned with CamScanner
The Banker’s Algorithm then checks to see if a process can be completed without
overloading the system. It does this by subtracting the amount of each resource used by the
process from the available matrix and adding it to the need matrix. If the result is in a safe
state, the process is allowed to proceed, otherwise, it is blocked until more resources
become available.
The Banker’s Algorithm is an effective way to prevent deadlocks in multiprogramming
systems. It is used in many operating systems, including Windows and Linux. In addition,
it is used in many other types of systems, such as manufacturing systems and banking
systems.
The Banker’s Algorithm is a powerful tool for resource allocation problems, but it is not
foolproof. It can be fooled by processes that consume more resources than they need, or by
processes that produce more resources than they need. Also, it can be fooled by processes
that consume resources in an unpredictable manner. To prevent these types of problems, it
is important to carefully monitor the system to ensure that it is in a safe state.
3. Deadlock Detection: Deadlock detection is used by employing an algorithm that tracks
the circular waiting and kills one or more processes so that the deadlock is removed. The
system state is examined periodically to determine if a set of processes is deadlocked. A
deadlock is resolved by aborting and restarting a process, relinquishing all the resources
that the process held.
 This technique does not limit resource access or restrict process action.
 Requested resources are granted to processes whenever possible.
 It never delays the process initiation and facilitates online handling.
 The disadvantage is the inherent pre-emption losses.
4. Deadlock Ignorance: In the Deadlock ignorance method the OS acts like the deadlock
never occurs and completely ignores it even if the deadlock occurs. This method only
applies if the deadlock occurs very rarely. The algorithm is very simple. It says ” if the
deadlock occurs, simply reboot the system and act like the deadlock never occurred.”
That’s why the algorithm is called the Ostrich Algorithm.
Advantages:
 Ostrich Algorithm is relatively easy to implement and is effective in most cases.
 It helps in avoiding the deadlock situation by ignoring the presence of
deadlocks.
Disadvantages:
 Ostrich Algorithm does not provide any information about the deadlock
situation.
 It can lead to reduced performance of the system as the system may be blocked
for a long time.
 It can lead to a resource leak, as resources are not released when the system is
blocked due to deadlock.

5. Examine deadlock Avoidance in detail with Bankers Algorithm.


Banker’s Algorithm

Multiple instances
Each process must a priori claim maximum use
When a process requests a resource it may have to wait
When a process gets all its resources it must return them in a finite amount of time
Let n
= number of processes, and m = number of resources types.

Scanned with CamScanner


Available: Vector of length m. If available [j] = k, there are k instances of resource
type
Rjavailable
Max: n x m matrix. If Max [i,j] = k, then process Pimay request at most k

instances of resource type Rj


Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currentlyallocated k instances
of

Rj

Need: n x m matrix. If Need[i,j] = k, then Pi may need k more instances of

Rjto complete its task


Need [i,j] = Max[i,j] – Allocation [i,j]

Safety Algorithm
1. Let Work and Finish be vectors of length m and n,respectively.
2. Initialize: Work = Available
Finish [i] = false fori = 0, 1, …,n- 1
3. Find an isuch that both:
(a) Finish [i] = false
(b) Needi=Work
If no such iexists, go to step 4
4. Work = Work +
Allocationi Finish[i] = truego to step 2
5. IfFinish [i] == true for all i, then the system is in a safe state
6. Resource-Request Algorithm for Process Pi
Request = request vector for process Pi. If Requesti[j] = k then process Pi wants

k instances of resource type Rj


raise error condition, since
process has exceeded its
maximum claim
2. If Requesti£Available, go
to step 3. Otherwise Pi must wait,
since resources are not available
3. Pretend to allocate requested resources to Pi by modifying the state as
follows:
Available = Available –
Request; Allocationi=
Alloc
Ationi + Requesti;Needi=Needi – Requesti;
o If safe the resources are allocated to Pi
o If unsafe Pi must wait, and the old resource-allocation state is
restored

Example of Banker’s Algorithm(REFER CLASS NOTES)


consider 5 processes P0 through
P4; 3 resource types:
A (10 instances), B (5instances), and C (7 instances)
Scanned with CamScanner
Snapshot at time T0:
Allocati Max Available
on
ABC ABC ABC
P0 0 1 0 753 332
P1 2 0 0 322
P2 3 0 2 902
P3 2 1 1 222
P4 0 0 2 433
Σ The content of the matrix Need is defined to be Max
– Allocation Need A B C

The system is in a safe state since the sequence <P1, P3, P4, P2, P0>
satisfies safety criteria P1 Request (1,0,2)
Check that Request £ Available (that is, (1,0,2) £ (3,3,2) true

Allocation Need Available

ABC ABC ABC


P0 0 1 0 743 230
P1 3 0 2 020
P2 3 0 2 600
P3 2 1 1 011
P4 0 0 2 431

Executing safety algorithm shows that sequence <P1, P3, P4, P0, P2> satisfies safety requirement

6. Interpret various methods for Handling Deadlocks?

Deadlock is a situation where a process or a set of processes is blocked, waiting for some
other resource that is held by some other waiting process. It is an undesirable state of the
system. The following are the four conditions that must hold simultaneously for a
deadlock to occur.
1. Mutual Exclusion – A resource can be used by only one process at a time. If
another process requests for that resource then the requesting process must be
delayed until the resource has been released.
2. Hold and wait – Some processes must be holding some resources in the non-
shareable mode and at the same time must be waiting to acquire some more
resources, which are currently held by other processes in the non-shareable
mode.
3. No pre-emption – Resources granted to a process can be released back to the
system only as a result of voluntary action of that process after the process has
completed its task.
4. Circular wait – Deadlocked processes are involved in a circular chain such that
each process holds one or more resources being requested by the next process in
the chain.
Methods of handling deadlocks: There are four approaches to dealing with deadlocks.
1. Deadlock Prevention
2. Deadlock avoidance (Banker's Algorithm)

Scanned with CamScanner


3. Deadlock detection & recovery
4. Deadlock Ignorance (Ostrich Method)

9. Apply Deadlock Detection scheme for Several Instances of a resource Type.

The OS can detect the deadlocks with the help of Resource allocation graph.
The OS can detect the deadlocks with the help of Resource allocation graph.
In single instanced resource types, if a cycle is being formed in the system then there will
definitely be a deadlock.
Multiple instanced resource type graph, detecting a cycle is not just enough. We have to apply the
safety algorithm on the system by converting the resource allocation graph into the allocation
matrix and request matrix.

1. Process vertex – Every process will be represented as a process vertex. Generally, the process will be
represented with a circle.
2. Resource vertex – Every resource will be represented as a resource vertex. It is also two type –

• Single instance type resource – It represents as a box, inside the box, there will be one dot. So the
number of dots indicate how many instances are present of each resource type.

• Multi-resource instance type resource – It also represents as a box, inside the box, there will be many
dots present.

Scanned with CamScanner


From the above example, it is not possible to say the RAG is in a safe state or in an unsafe state. So to see the
state of this RAG, let’s construct the allocation matrix and request matrix.

Scanned with CamScanner


Checking deadlock (safe or not)

Hence, there is no deadlock in this RAG.

Scanned with CamScanner


Allocation & Request table

Scanned with CamScanner


Available resource is = (0, 0), but requirement are (0, 1), (1, 0) and (1, 0).

So you can’t fulfill any one requirement. Therefore, it is in deadlock.

10. Using Banker’s Algorithm, assume that there are 5 processes, P0 through P4, and 4 types of
resources. At T0 we have the following system state:

Allocation Max Available

A B C D A B C D A B C D

P1 0 1 1 0 0 2 1 0 1 5 2 0

P2 1 2 3 1 1 6 5 2

P3 1 3 6 5 2 3 6 6

P4 0 6 3 2 0 6 5 2

P5 0 0 1 4 0 6 5 6

1. Create the need matrix (max-allocation)

2. Use the safety algorithm to test if the system is in a safe state.

Scanned with CamScanner


Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
4.Discuss in detail about various deadlock handling
strategies.
Deadlock is a situation where a process or a set of processes is blocked, waiting
for some other resource that is held by some other waiting process. It is an
undesirable state of the system. The following are the four conditions that must
hold simultaneously for a deadlock to occur.
6. Mutual Exclusion – A resource can be used by only one process at a
time. If another process requests for that resource then the requesting
process must be delayed until the resource has been released.
7. Hold and wait – Some processes must be holding some resources in
the non-shareable mode and at the same time must be waiting to acquire
some more resources, which are currently held by other processes in the
non-shareable mode.
8. No pre-emption – Resources granted to a process can be released back
to the system only as a result of voluntary action of that process after
the process has completed its task.
9. Circular wait – Deadlocked processes are involved in a circular chain
such that each process holds one or more resources being requested by
the next process in the chain.
Methods of handling deadlocks: There are four approaches to dealing with
deadlocks.
1. Deadlock Prevention
2. Deadlock avoidance (Banker's Algorithm)
3. Deadlock detection & recovery
4. Deadlock Ignorance (Ostrich Method)
These are explained below.
1. Deadlock Prevention: The strategy of deadlock prevention is to design the
system in such a way that the possibility of deadlock is excluded. The indirect
methods prevent the occurrence of one of three necessary conditions of deadlock
i.e., mutual exclusion, no pre-emption, and hold and wait. The direct method
prevents the occurrence of circular wait. Prevention techniques – Mutual
exclusion – are supported by the OS. Hold and Wait – the condition can be
prevented by requiring that a process requests all its required resources at one
time and blocking the process until all of its requests can be granted at the same
time simultaneously. But this prevention does not yield good results because:
 long waiting time required
 inefficient use of allocated resource
 A process may not know all the required resources in advance
No pre-emption – techniques for ‘no pre-emption are’
 If a process that is holding some resource, requests another resource
that can not be immediately allocated to it, all resources currently being
held are released and if necessary, request again together with the
additional resource.

Scanned with CamScanner


 If a process requests a resource that is currently held by another
process, the OS may pre-empt the second process and require it to
release its resources. This works only if both processes do not have the
same priority.
Circular wait One way to ensure that this condition never holds is to impose a
total ordering of all resource types and to require that each process requests
resources in increasing order of enumeration, i.e., if a process has been allocated
resources of type R, then it may subsequently request only those resources of
types following R in ordering.
2. Deadlock Avoidance: The deadlock avoidance Algorithm works by
proactively looking for potential deadlock situations before they occur. It does
this by tracking the resource usage of each process and identifying conflicts that
could potentially lead to a deadlock. If a potential deadlock is identified, the
algorithm will take steps to resolve the conflict, such as rolling back one of the
processes or pre-emptively allocating resources to other processes. The Deadlock
Avoidance Algorithm is designed to minimize the chances of a deadlock
occurring, although it cannot guarantee that a deadlock will never occur. This
approach allows the three necessary conditions of deadlock but makes judicious
choices to assure that the deadlock point is never reached. It allows more
concurrency than avoidance detection A decision is made dynamically whether
the current resource allocation request will, if granted, potentially lead to
deadlock. It requires knowledge of future process requests. Two techniques to
avoid deadlock :
3. Process initiation denial
4. Resource allocation denial
Advantages of deadlock avoidance techniques:
 Not necessary to pre-empt and rollback processes
 Less restrictive than deadlock prevention
Disadvantages :
 Future resource requirements must be known in advance
 Processes can be blocked for long periods
 Exists a fixed number of resources for allocation
Banker’s Algorithm:
The Banker’s Algorithm is based on the concept of resource allocation graphs. A
resource allocation graph is a directed graph where each node represents a
process, and each edge represents a resource. The state of the system is
represented by the current allocation of resources between processes. For
example, if the system has three processes, each of which is using two resources,
the resource allocation graph would look like this:
Processes A, B, and C would be the nodes, and the resources they are using
would be the edges connecting them. The Banker’s Algorithm works by
analyzing the state of the system and determining if it is in a safe state or at risk
of entering a deadlock.

Scanned with CamScanner


To determine if a system is in a safe state, the Banker’s Algorithm uses two
matrices: the available matrix and the need matrix. The available matrix contains
the amount of each resource currently available. The need matrix contains the
amount of each resource required by each process.
The Banker’s Algorithm then checks to see if a process can be completed without
overloading the system. It does this by subtracting the amount of each resource
used by the process from the available matrix and adding it to the need matrix. If
the result is in a safe state, the process is allowed to proceed, otherwise, it is
blocked until more resources become available.
The Banker’s Algorithm is an effective way to prevent deadlocks in
multiprogramming systems. It is used in many operating systems, including
Windows and Linux. In addition, it is used in many other types of systems, such
as manufacturing systems and banking systems.
The Banker’s Algorithm is a powerful tool for resource allocation problems, but
it is not foolproof. It can be fooled by processes that consume more resources
than they need, or by processes that produce more resources than they need. Also,
it can be fooled by processes that consume resources in an unpredictable manner.
To prevent these types of problems, it is important to carefully monitor the
system to ensure that it is in a safe state.
3. Deadlock Detection: Deadlock detection is used by employing an algorithm
that tracks the circular waiting and kills one or more processes so that the
deadlock is removed. The system state is examined periodically to determine if a
set of processes is deadlocked. A deadlock is resolved by aborting and restarting
a process, relinquishing all the resources that the process held.
 This technique does not limit resource access or restrict process action.
 Requested resources are granted to processes whenever possible.
 It never delays the process initiation and facilitates online handling.
 The disadvantage is the inherent pre-emption losses.
4. Deadlock Ignorance: In the Deadlock ignorance method the OS acts like the
deadlock never occurs and completely ignores it even if the deadlock occurs. This
method only applies if the deadlock occurs very rarely. The algorithm is very
simple. It says ” if the deadlock occurs, simply reboot the system and act like the
deadlock never occurred.” That’s why the algorithm is called the Ostrich
Algorithm.
Advantages:
 Ostrich Algorithm is relatively easy to implement and is effective in
most cases.
 It helps in avoiding the deadlock situation by ignoring the presence of
deadlocks.
Disadvantages:
 Ostrich Algorithm does not provide any information about the deadlock
situation.

Scanned with CamScanner


 It can lead to reduced performance of the system as the system may be
blocked for a long time.
 It can lead to a resource leak, as resources are not released when the
system is blocked due to deadlock.

10. Examine deadlock Avoidance in detail with Bankers


Algorithm.

Banker’s Algorithm

Multiple instances
Each process must a priori claim maximum use
When a process requests a resource it may have to wait
When a process gets all its resources it must return them in a finite
amount of time Let n
= number of processes, and m = number of resources types.
Available: Vector of length m. If available [j] = k, there are k instances of
resource type
Rjavailable
Max: n x m matrix. If Max [i,j] = k, then process Pimay request at most k

instances of resource type Rj


Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currentlyallocated k
instances of

Rj

Need: n x m matrix. If Need[i,j] = k, then Pi may need k more instances of

Rjto complete its task


Need [i,j] = Max[i,j] – Allocation [i,j]

Safety Algorithm
7. Let Work and Finish be vectors of length m and n,respectively.
8. Initialize: Work = Available
Finish [i] = false fori = 0, 1, …,n- 1
9. Find an isuch that both:
(c) Finish [i] = false
(d) Needi=Work
If no such iexists, go to step 4
10. Work = Work
+ Allocationi
Finish[i] = truego to step 2

Scanned with CamScanner


11. IfFinish [i] == true for all i, then the system is in a safe state
12. Resource-Request Algorithm for Process Pi
Request = request vector for process Pi. If Requesti[j] = k then process Pi
wants

k instances of resource type Rj


raise error condition,
since process has
exceeded its maximum
claim
4. If
Requesti£Available, go to
step 3. Otherwise Pi must
wait, since resources are
not available
5. Pretend to allocate requested resources to Pi by modifying
the state as follows:
Available = Available –
Request; Allocationi=
Alloc
Ationi + Requesti;Needi=Needi – Requesti;
o If safe the resources are allocated to Pi
o If unsafe Pi must wait, and the old resource-allocation
state is restored

Example of Banker’s Algorithm(REFER CLASS NOTES)


consider 5 processes P0 through
P4; 3 resource types:
A (10 instances), B (5instances), and C (7 instances)

Snapshot at time T0:


Allocati Max Available
on
ABC ABC ABC
P0 0 1 0 753 332
P1 2 0 0 322
P2 3 0 2 902
P3 2 1 1 222
P4 0 0 2 433
Σ The content of the matrix Need is defined to be Max
– Allocation Need A B C

The system is in a safe state since the sequence <P1, P3, P4, P2, P0>

Scanned with CamScanner


satisfies safety criteria P1 Request (1,0,2)
Check that Request £ Available (that is, (1,0,2) £ (3,3,2)
tru
e

Allocation Need Available

ABC ABC ABC


P0 0 1 0 743 230
P1 3 0 2 020
P2 3 0 2 600
P3 2 1 1 011
P4 0 0 2 431

Executing safety algorithm shows that sequence <P1, P3, P4, P0, P2> satisfies safety
requirement

6. Interpret various methods for Handling Deadlocks?

Deadlock is a situation where a process or a set of processes is blocked, waiting


for some other resource that is held by some other waiting process. It is an
undesirable state of the system. The following are the four conditions that must
hold simultaneously for a deadlock to occur.
5. Mutual Exclusion – A resource can be used by only one process at a
time. If another process requests for that resource then the requesting
process must be delayed until the resource has been released.
6. Hold and wait – Some processes must be holding some resources in
the non-shareable mode and at the same time must be waiting to acquire
some more resources, which are currently held by other processes in the
non-shareable mode.
7. No pre-emption – Resources granted to a process can be released back
to the system only as a result of voluntary action of that process after
the process has completed its task.
8. Circular wait – Deadlocked processes are involved in a circular chain
such that each process holds one or more resources being requested by
the next process in the chain.
Methods of handling deadlocks: There are four approaches to dealing with
deadlocks.
1. Deadlock Prevention
2. Deadlock avoidance (Banker's Algorithm)
3. Deadlock detection & recovery
4. Deadlock Ignorance (Ostrich Method)

Scanned with CamScanner

You might also like