In this article we will study in brief about what is Deadlock followed by Deadlock Ignorance in Operating System.
What is Deadlock?
If each process in the set of processes is waiting for an event that only another process in the set can cause it is actually referred as called Deadlock. In other words, one event which has to happen by one process with the presence of another process in the process set, this situation is referred as Deadlock.
Let us understand the above illustrated definition of Deadlock with the help of an example shown in below section.
Example of a 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.
After analyzing deadlock with the help of an example (shown above), let us see the four necessary condition which may lead to deadlock, shown in below illustrated section.
Necessary conditions for Deadlock:
There are 4 conditions which leads to Deadlock. They are as follows:
- 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. If any of the above illustrated conditions fails to happen, then we may conclude that there is no deadlock in the system.
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. This Ostrich algorithm is the most widely used technique in order to ignore the deadlock and also it used for all the single end-users uses. If there is deadlock in the system, then the OS will reboot the system in order to function well. 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.
Ignoring the possibility of deadlock in operating systems can have both advantages and disadvantages.
- Simplicity: Ignoring the possibility of deadlock can make the design and implementation of the operating system simpler and less complex.
- Performance: Avoiding deadlock detection and recovery mechanisms can improve the performance of the system, as these mechanisms can consume significant system resources.
- Unpredictability: Ignoring deadlock can lead to unpredictable behavior, making the system less reliable and stable.
- System crashes: If a deadlock does occur and the system is not prepared to handle it, it can cause the entire system to crash, resulting in data loss and other problems.
- Reduced availability: Deadlocks can cause processes to become blocked, which can reduce the availability of the system and impact user experience.
In general, the disadvantages of ignoring deadlock outweigh the advantages. It is important to implement effective deadlock prevention and recovery mechanisms in operating systems to ensure the stability, reliability, and availability of the system.
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation
Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation