Deadlock 1
Deadlock 1
Example of Deadlock
A real-world example would be traffic, which is going only in one
direction.
Here, a bridge is considered a resource.
So, when Deadlock happens, it can be easily resolved if one car backs up
(Preempt resources and rollback).
Several cars may have to be backed up if a deadlock situation occurs.
So starvation is possible.
Deadlock Detection
A deadlock occurrence can be detected by the resource scheduler. A resource
scheduler helps OS to keep track of all the resources which are allocated to
different processes. So, when a deadlock is detected, it can be resolved using
the below-given methods:
Deadlock Prevention:
It's important to prevent a deadlock before it can occur. The system checks
every transaction before it is executed to make sure it doesn't lead the deadlock
situations. Such that even a small change to occur dead that an operation which
can lead to Deadlock in the future it also never allowed process to execute.
It is a set of methods for ensuring that at least one of the conditions cannot
hold.
No preemptive action:
No Preemption - A resource can be released only voluntarily by the process
holding it after that process has finished its task
Mutual Exclusion:
Mutual Exclusion is a full form of Mutex. It is a special type of binary semaphore
which used for controlling access to the shared resource. It includes a priority
inheritance mechanism to avoid extended priority inversion problems. It allows
current higher priority tasks to be kept in the blocked state for the shortest time
possible.
Resources shared such as read-only files never lead to deadlocks, but resources,
like printers and tape drives, needs exclusive access by a single process.
Circular Wait:
It imposes a total ordering of all resource types. Circular wait also requires that
every process request resources in increasing order of enumeration.
Deadlock Avoidance
It is better to avoid a deadlock instead of taking action after the Deadlock has
occurred. It needs additional information, like how resources should be used.
Deadlock avoidance is the simplest and most useful model that each process
declares the maximum number of resources of each type that it may need.
Avoidance Algorithms
The deadlock-avoidance algorithm helps you to dynamically assess the
resource-allocation state so that there can never be a circular-wait situation.
Deadlock Starvation
The deadlock situation occurs when one of the processes got Starvation is a situation where all the low prio
blocked. blocked, and the high priority processes execu
Every Deadlock always has starvation. Every starvation does n't necessarily have a d
Deadlock happens then Mutual exclusion, hold and wait. Here, It happens due to uncontrolled priority and re
preemption and circular wait do not occur simultaneously.
Advantages of Deadlock
Here, are pros/benefits of using Deadlock method
This situation works well for processes which perform a single burst of
activity
No preemption needed for Deadlock.
Convenient method when applied to resources whose state can be saved
and restored easily
Feasible to enforce via compile-time checks
Needs no run-time computation since the problem is solved in system
design
Summary:
Deadlock Definition: It is a situation that occurs in OS when any process
enters a waiting state because another waiting process is holding the
demanded resource
Circular waiting happens when one process is waiting for the resource,
which is held by the second process, which is also waiting for the resource
held by the third process etc.
A deadlock occurrence can be detected by the resource scheduler.
It's important to prevent a deadlock before it can occur.
A resource can be released only voluntarily by the process holding it after
that process has finished its task.
Mutual Exclusion is a full form of Mutex. It is a special type of binary
semaphore which used for controlling access to the shared resource.
Hold and wait is a condition where processes must be stopped from
holding single or multiple resources while simultaneously waiting for one
or more others.
Deadlock avoidance is the simplest and most useful model that each
process declares the maximum number of resources of each type that it
may need.
The deadlock-avoidance algorithm helps you to dynamically assess the
resource-allocation state so that there can never be a circular-wait
situation.
Deadlock is an infinite process, whereas starvation is a long waiting but
not an infinite process.