If each process in the set is waiting for an event that only another process in the set can cause is called Deadlock.
Suppose process A holds resource C and process B holds resource D.
Now process A request for resource D and process B request for resource C but none of the process will get these resources as both the resources are already busy with some other process hence neither of them can proceed further. This situation is called Deadlock.
There are 4 conditions which leads to Deadlock. They are as follow
- Mutual exclusion condition
- Hold and wait condition
- No preemption condition
- Circular wait condition
All the above four condition should be present for deadlock to occur.
Deadlock Ignorance :
Stick your head in the sand and pretend there is no problem at all, this method of solving any problem is called Ostrich Algorithm. The method of solving any problem varies according to the people.
Scientists all over the world believe that the most efficient method to deal with deadlock is deadlock prevention. But the Engineers that deal with the system believe that deadlock prevention should be paid less attention as there are very less chances for deadlock occurrence.
System failure, compiler error, programming bugs, hardware crashes that occur once a week should be paid more attention rather than deadlock problem that occur once in years. Therefore most of the engineers don’t pay much amount in eliminating the deadlock.
Many operating systems suffers from deadlock that are not even detected and then automatically broke. Just as an explanation we know that the number of processes is determined by the process table. Now as we know there are only finite number of slots in the process table and hence when the table is full the fork fails. Now the reasonable approach for the new fork has to wait and try again when the slot in the process table is empty.
Also, such problem is noticed while opening and closing file. The maximum time the file is opened is restricted and mention in the i-node table and thus similar problem is observed when the table is filled. Another limited resource is mentioned as swap space. In fact, all the table storing data in the operating system has finite resource limit. It might happen that a collection of n processes might each claim 1/n of the total, Should we clear all of these and then each try to claim another one?
Including UNIX and WINDOWS, all the operating system ignore the deadlock first assuming that the user is restricted to one process. The deadlock ignorance comes into picture frequently because by this method deadlock is eliminated for free rather than spending much on other deadlock prevention methods also putting some inconvenient restrictions on process. Thus we have to decide between the correctness and convenience between the different methods of solving the deadlock.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.