A
deadlock is a situation in which some process wait for each other actions
indefinitely. Process involved in a deadlock remains blocked permanently.
Operating
system handles only deadlock cause by sharing of resources in the system.
Deadlock in
resource allocation: -
·
Request: - A
process requests a resource through a system call. If the resources are
available then the kernel allocates it to the process immediately; otherwise it
changes the state of the process to blocked i.e., if the request cannot be
granted immediately then the requesting process must wait until it can acquire
the resource.
·
Allocation:- The
process becomes the holder of the resource allocated to it. The resource state
information is updated and the state of the process is changed to ready.
·
Release: - A process
releases the resource through a system call. If some processes are blocked on
the allocation event for the resource, the kernel uses some tie breaking rule.
v Deadlock prevention: -
d. Circular
wait: - Suppose
we have three resources: tape drive,
disk drive and printer. A process which meant to access disk drive and printer
should firstly access disk drive and then printer. That is resources are
allocated according to their numbering.
a. Mutual Exclusion (Non Sharable Resource): - This condition
must hold for non-sharable resources. Ex: - printer cannot be simultaneously
share by several processes.
If
many processes attempt to open a read only file at the same time they can be
granted simultaneous access to the file. A process never needs to wait for a
sharable resource.
Generally
deadlock cannot be prevented by denying this condition.
b. Hold and Wait: - To stop this
condition two protocol can be used.
1. Each process
to request and allocated all its resource before it begins execution.
2. A process
can request any resource it must release all its currently allocated resources.
These protocols have two disadvantages:-
1. Resource
utilization should be low (protocol 1).
2. A process
that needs many resources may have to wait indefinitely (protocol 2).
c. No pre-emption: - If a process
requesting a resource that can’t be currently allocated to it, then all
currently held resources are pre-empted. The process will be restarted only
when it regains its old as well new resources it is requesting.
v Deadlock avoidance: -
a.
Safe state
b.
Resource allocation graph method
c.
Banker’s algorithm
v Deadlock detection: - If a system doesn’t apply with deadlock prevention or deadlock
avoidance then a deadlock may occur. Deadlock can be detected by using RAG algorithm and Banker’s
algorithm.
v Deadlock resolution or recovery: - When a deadlock is detected a system can be recovered from the
deadlock automatically or manually (by rebooting the system).
2. We have to add some new units of resource
required.
There are two options to break a deadlock.
1. We have to
terminate some process so that a circular wait condition breaks and this way
some resources also become free for the running process.
For detailed information download PDF
Downloading server are below
No comments:
Post a Comment