You are on page 1of 15

Presentation on Deadlock

By Ankita Goyal

Contents

Introduction to deadlock Conditions for deadlock mutual exclusion Hold and wait No preemption Circular wait Handling deadlock Ignoring deadlock Deadlock detection Deadlock prevenntion Deadlock avoidance

The Deadlock problem

In a computer system deadlocks arise when members of a group of processes which hold resources are blocked indefinitely from access to resources held by other processes within the group.

24444

EXAMPLES:
"It takes money to make money". You can't get a job without experience; you can't get experience without a job.

BACKGROUND:
The cause of deadlocks: Each process needing what another process has. This results from sharing resources such as memory, devices, links. Under normal operation, a resource allocations proceed like this::

1. 2. 3.

Request a resource (suspend until available if necessary ). Use the resource. Release the resource

Conditions for deadlocks (Coffman conditions)


Mutual exclusion. No resource can be shared by more than one process at a time. Hold and wait. There must exist a process that is holding at least one resource and is waiting to acquire additional resources that are currently being held by other processes.

Conditions for deadlock contd..

No preemption. The operating system must not de-allocate resources once they have been allocated; they must be released by the holding process voluntarily. Circular wait. A process must be waiting for a resource which is being held by another process, which in turn is waiting for the first process to release the resource.
5

Strategies for handling deadlocks


Ignoring deadlock: It is assumed that a deadlock will never occur application of the Ostrich algorithm used when the time intervals between occurrences of deadlocks are large and the data loss incurred each time is tolerable

Deadlock Detection: deadlocks are allowed to occur After a deadlock is detected, it can be corrected by using one of the following methods:

Process termination Resource preemption


7

Deadlock Prevention

Deadlock prevention works by preventing one of the four Coffman conditions from occurring.

Hold and wait condition:

1. A process acquires all the needed resources simultaneously before it begins its execution, therefore breaking the hold and wait condition. E.g. In the dining philosophers problem, each philosopher is required to pick up both forks at the same time. If he fails, he has to release the fork(s) (if any) he has acquired.
9

Circular wait

All resources are assigned unique numbers. A process may request a resource with a unique number I only if it is not holding a resource with a number less than or equal to I and therefore breaking the circular wait condition. Drawback: over-cautions.

10

Mutual Exclusion

Practically it is impossible to provide a method to break the mutual exclusion condition since most resources are intrinsically non-sharable, e.g., two philosophers cannot use the same fork at the same time.

11

Deadlock Avoidance

Deadlock can be avoided if certain information about processes are available to the operating system before allocation of resources, such as which resources a process will consume in its lifetime

12

You might also like