What is a deadlock in operating system? Is it a state where two ore more operations are waiting for each other, say a computing action 'A' is waiting for action 'B' to complete, while action 'B' can only execute when 'A' is completed. Such a situation would be called a deadlock. In operating systems, a deadlock situation is arrived when computer resources required for complete of a computing task are held by another task that is waiting to execute. The system thus goes into an indefinite loop resulting into a deadlock. The deadlock in operating system seems to be a common issue in multiprocessor systems, parallel and distributed computing setups.
A deadlock is a situation when a process in the system has acquired some resources and waiting for more resources which are acquired by some other process which in turn is waiting for the resources acquired by this process. Hence, none of them can proceed and OS cant do any work.
One definition of an operating system is a resource allocator. There are many resources that can be allocated to only one process at a time. Sometimes a process has to reserve more than one resource. In general, resources allocated to a process are not preemptable; this means that once a resource has been allocated to a process, there is no simple mechanism by which the system can take the resource back from the process unless the process voluntarily gives it up or the system administrator kills the process. This can lead to a situation called deadlock. A set of processes or threads is deadlocked when each process or thread is waiting for a resource to be freed which is controlled by another process. Here is an example of a situation where deadlock can occur.
You should also note this - In order for deadlock to occur, four conditions must be true. Mutual exclusion - Each resource is either currently allocated to exactly one process or it is available. (Two processes cannot simultaneously control the same resource or be in their critical section). Hold and Wait - processes currently holding resources can request new resources No preemption - Once a process holds a resource, it cannot be taken away by another process or the kernel. Circular wait - Each process is waiting to obtain a resource which is held by another process.
a process A needs some resource R1 which is acquired by some other process B,and process B needed some resource R2 ,which is acquired by process A.Hence none of the process acquired the required resource as both the respective process are in waiting condition and hence deadlock occurs.
Just think of a real time scenario A situation when brother are fighting for playing video game One brother has remote control for playing and other has game cd or whaever we call No only one person can play but both are not ready to cooperate and hence it results in deadlock, no one can play now, same is with operating system I hope this is very simple example to get a clear idea of deadlock,
A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause including itself.
In a multiprogramming environment, each & every process is waiting for the resources. These resources are held by other processes & the requesting process may enter a waiting state (sometimes it takes infinite time). Clearly, a deadlock can be defined as : "A set of processes is deadlocked, if each process in the set is waiting for an event that only another process in the set can cause (including itself)." Necessary Conditions for deadlock: Mutual exclusion Hold & wait No preemption Circular wait Eg: Traffic jam situation is the best example for deadlock.
we can simply quote it as " when one process is executing no other process is allowed to execute at the same time. So when one process is under execution if another process requests for the execution then a deadlock state occurs".. and it should satisfy the four conditions 1. Mutual exclusion. 2. Hold and wait. 3. No preumption. 4. Circular wait. thats it.....
Oh you should totally look up the Dining Philosophers problem - http://en.wikipedia.org/wiki/Dining_philosophers_problem