0% found this document useful (0 votes)
43 views2 pages

Deadlocks

A deadlock occurs when a set of processes are blocked waiting for resources held by each other, meeting four conditions: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be prevented by ensuring that not all four conditions are met simultaneously, such as eliminating circular wait by imposing a total ordering of resource requests. Deadlock avoidance involves dynamically determining if a resource allocation could potentially lead to a deadlock.

Uploaded by

nehavj664
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Deadlocks

A deadlock occurs when a set of processes are blocked waiting for resources held by each other, meeting four conditions: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be prevented by ensuring that not all four conditions are met simultaneously, such as eliminating circular wait by imposing a total ordering of resource requests. Deadlock avoidance involves dynamically determining if a resource allocation could potentially lead to a deadlock.

Uploaded by

nehavj664
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Deadlocks:

A deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource acquired by some other process.

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.

1)Deadlock Prevention
We can prevent a Deadlock by eliminating any of the above four conditions.

Eliminate Mutual Exclusion:

It is not possible to dis-satisfy the mutual exclusion because some resources, such as
the tape drive and printer, are inherently non-shareable

No Preemption –

If a process that is holding some resources & requests another resource that cannot be
immediately allocated to it, then all resources currently being held are released.
Preempted resources are added to the list of resources for which the process is waiting.
Process will be resumed only when it can regain its old resources, as well as the new ones
that it is requesting

Eliminate Hold and wait:

Allocate all required resources to the process before the start of its execution, this
way hold and wait condition is eliminated but it will lead to low device utilization.
for example, if a process requires a printer at a later time and we have allocated a
printer before the start of its execution printer will remain blocked till it has
completed its execution. The process will make a new request for resources after
releasing the current set of resources. This solution may lead to starvation.

Circular Wait:

impose a total ordering of all resource types and ensure that each process requests
resources in an increasing order. This prevents the formation of circular wait chains.
Example: If there are resources A, B, and C, a process might be allowed to request
resources only in the order A, B, C, preventing circular waits.

B)Deadlock avoidance:
Deadlock avoidance is a strategy employed in operating systems to dynamically assess the
system's state and determine whether a particular resource allocation request may
potentially lead to a deadlock.

Critical section:

Mutual exclusion:

You might also like