What do you mean by Deadlock in CPU?
A deadlock is a situation where a group of processes is permanently blocked as
a result of each process having acquired a set of resources needed for its
completion and having to wait for the release of the remaining resources held
by others thus making it impossible for any of the deadlocked process to proceed.
For example assume a system with one tape drive and one plotter.Process P1 requests
the plotter and process P2 requests the tape drive. Both requests are granted. Now
Process P1 request the tape drive(without giving the plotter) and process P2 requests
plotter(without releasing tape drive) .Neither request can be granted so both processes
enter a situation called the deadlock situation.
Hey guys before we learn more about deadlocks we must understand about the
type of resources.
There are mainly two types of resources:
Pre emptive Resources:This process can be taken away from the process with no ill
effects.For eg Memory is an example of a pre-emptable resource .
Non Pre-emptive Resources:This resource cannot be taken away from the process
without causing ill effect.For example CD Rom
It is to be noted that relocating resources can resolve deadlocks that involve
pre-emptable resources while Non pre-emptable resources are difficult to deal with.
Characteristics of Deadlock:
There are basically four necessary conditions that leads to occurence of deadlock.
They are as follows:
1. Mutual Exclusion:
In this the resources used are non shareable At least one resource must be held in a
non shareable mode.. If another process request that resource the requesting process must
be delayed until the resource has been released.
2:Hold and Wait Condition
In this condition a requesting process already holds resources and waits
for the requested resources. A process holding a resource allocated to it waits for
an additional resources that is/are currently being held by other resources
3.No Preemptive condition:
Resources already allocated to a process cannot be pre-empted.Resources cannot be
removed forcibly from the processes.After completion they will be released
voluntarily by the process holding it
4. Circular Wait Condition:
The processes in the system form a circular list or chain where each process in the list
is waiting for a resource hold by the next process in the list.