740 views
0 votes
0 votes
We know that whenever a process needs i/o time it goes to block/wait state. At that time cpu is idle and it can run other processes. What happens during the deadlock ? In which state do the processes go, so that the cpu freezes ? If all the processes during deadlock, go into block state then why does the cpu freezes ? The cpu should stay idle, but it should not freeze . Can anyone clarify ?

1 Answer

0 votes
0 votes

For starters, all the processes going in a deadlock simultaneously, is a very very rare occurrence, at least on the CPUs our generation is used to. In fact its so rare that major names in the market, like Windows and Ubuntu, do not have any deadlock resolving mechanism at all. The ultimate solution is that the user gets frustrated and restarts the system.

But still, if a condition occurs wherein all the processes are in deadlock, then CPU goes in an idle state (as there is no process to execute) and its same as what we call as freezing or "hang". After some time, if one of the processes is killed the deadlock may be resolved and the system starts running again. But if one the process stuck in deadlock is of kernel type, the only solution is a total restart.$^{[1]}$

Also, there may be the case wherein not all, but only a few processes are in a deadlock. In that case, the CPU may be (in fact is) used by other processes. Its one of those moments when one of our application (say Chrome becomes unresponsive) while rest of the applications are running well and good.

Related questions

9 votes
9 votes
1 answer
4
Nancy Pareta asked May 28, 2018
4,203 views
The time complexity of banker's algorithm to avoid deadlock having $n$ processes and $m$ resources is?