0% found this document useful (0 votes)
5 views

Unit 3 Os

Uploaded by

nascdrsridevis
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Unit 3 Os

Uploaded by

nascdrsridevis
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Operating System

UNIT 3
Deadlock
A deadlock is a situation where a set of processes is
blocked because each process is holding a resource and
waiting for another resource acquired by some other process
What is Deadlock?
Deadlock is a situation in computing where two or more
processes are unable to proceed because each is waiting for
the other to release resources
Example:
• Consider an example when two trains are coming toward each other
on the same track and there is only one track,
• none of the trains can move once they are in front of each other. This
is a practical example of deadlock.
https://youtu.be/MYgmmJJfdBg?si=xGCMropDhPsLXEFe
deadlock
How Does Deadlock occur in the Operating System?
A process in an operating system uses resources in the following way.
• Requests a resource
• Use the resource
• Releases the resource
• A situation occurs in operating systems when there are two or more
processes that hold some resources and wait for resources held by
other(s).
For example, in the below diagram,
Process 1 is holding Resource 1 and waiting for resource 2 which is
acquired by process 2,
and process 2 is waiting for resource 1.
Examples of Deadlock
There are several examples of deadlock. Someof them are mentioned
below.
1. The system has 2 tape drives. P0 and P1 each hold one tape drive and each
needs another one.
2. Semaphores A and B, initialized to 1, P0, and P1 are in deadlock as follows:
• P0 executes wait(A) and preempts.
• P1 executes wait(B).
• Now P0 and P1 enter in deadlock.
3. Assume the space is available for allocation of 200K bytes, and the
following sequence of events occurs.
Necessary Conditions for Deadlock in OS
Deadlock can arise if the following four conditions hold simultaneously
(Necessary Conditions)
• Mutual Exclusion: Two or more resources are non-shareable (Only one
process can use at a time).

• Hold and Wait: A process is holding at least one resource and waiting for
resources.

• No Preemption: A resource cannot be taken from a process unless the


process releases the resource.

• Circular Wait: A set of processes waiting for each other in circular form.
Deadlocks in Resource Allocation
Deadlocks in Resource Allocation
Handling deadlocks
Deadlock Detection and Resolution
Deadlock Prevention
Deadlock Avoidance.
Memory Management
:
Static and dynamic Memory Allocation
The Memory Allocation Model
Reuse of Memory
Contiguous Memory allocation
Non Contiguous Memory Allocation
.

You might also like