Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a
member of our community. Consider creating an
account or login.
Deadlocks are least possible though. They are very rare in OS. That is the reason why most of the OS present ignore the problem altogether and pretend that deadlocks never occur in the system. So they don't have any algorithm for deadlock detection/avoidance/prevention. Because of that they can't recover from the state when deadlock occurs. But as i said that deadlocks are very rare so avoiding the use of these algorithm is more cost effective and efficient. But you can not discard deadlocks as the reason computer hangs. But if that is only reason why computer hangs, then we have one or two hangs in a year😛.
Could be due to multiple of reasons -
1. CPU utilization goes to 100%
2. A program starts thrashing
3. Process queue for the CPU is so much that it cannot process all of them and slows down
Few reasons are:
1. May be a problem in hardware. Most of the time it will be due to RAM.
2. Deadlock may hang few process, and if they are important ones then you feel like the system has hanged, where as processes are waiting for resources to be released by other processes.
3. Memory images of code getting corrupted may be due to glitches or even due to faulty programs.
Deadlock can be explained this way.
Think there are 2 resources A & B and with a condition that at anytime only one can use the resources.
for example a file(resource) can be opened for write by only one process at a time, if other process tries to open it will be asked to wait.
Let there be 2 process P1 & P2
P1 is using resource A and at the same time it asks for resource B, still it has not freed resource A.
P2 is using resource B so OS stops P1 until resouce is freed by P2.
Meanwhile if it happens that P2 asks for resource A even before releasing B. then the condition is called Deadlock.
P1 is waiting for P2 to release B & P2 is waiting for P1 to release A.
Only OS can resolve this race condition. for example by giving error to P1 after certain time that Resource B is busy etc.,