What is a Deadlock Prevention Algorithm in Operating System?

Deadlock Prevention Algorithm in Operating System 

We used these conditions to prevent deadlock:

  1. Mutual Exclusion
  2. Hold on and Wait
  3. No preemption
  4. Circular Wait

1. 1.The mutual exclusion is a resource-based concept that prevents more than one process from using the same resource at once. This is fair, but it causes a deadlock. There is no way to wait for the resource if we have the possibility of using the same resource for multiple processes at once.


Deadlock Prevention Algorithm in Operating System



However, if the resources are not performing in a mutually exclusive way, then we can prevent the system becoming stuck.

Spooling: Spooling is shorthand for Simultaneous Perimeter Operations Online. Spooling is used for devices like Printer, Mouse, and Keyboard. Let's look at the workings of a printer's spooling process:

  • Memory is an associated component of a printer.
  • This memory allows us to store all of the jobs.
  • After collecting all jobs, the printer prints each job in FCFS (First Come First Serve). This method will ensure that no printing process takes place while the printer is busy.
  • The printer then collects the outputs once they are finished.

Spooling can help us stop mutual exclusion. However, there are two possible problems.

  1. Spooling cannot be used for all resources.
  2. Spooling can lead to rare situations in which processes need more space. However, it is not possible to force multiple processes to use the same resources. This approach is a failure and could lead to serious problems. We can therefore say that mutual exclusion cannot be violated.

2. 2.Hold and Wait refers to a situation where a process holds onto a resource but still waits for the right resources to complete its task. This situation can lead to deadlock as more than one process holds one resource and waits cyclically for the other resources. We need to devise a procedure that does not require any resource, or waits for any resource. This means that we must assign all resources necessary for the process to be executed before it can begin. Once this is done, execution can begin without any waiting.

This is possible only if we determine the resources required for the process before it starts. It sounds great, but it is impossible to do in a computer system. This is because no process can determine the resources needed at the beginning.

A set of instructions executed by the CPU is called a process. Each instruction can request different resources multiple times. The operating system cannot fix the demand for resources.

These are the issues that this approach faces:

Practically, it is impossible.

You may experience starvation if the process holds a resource for long periods of time.

3. No Preemption Deadlock occurs because once the process begins its execution, it can't be stopped. We can stop deadlock by removing the resources that could cause it. This is not the best approach, as if we take out a resource being used by the process it will be inconsistent with what we have done up to now.

Take, for example: Let's say we have a printer that is being used by a process. We take the printer and assign it to another process. This causes the printer to print inconsistent and ineffective data. This can also cause the printer to stop printing from the point it left.

4. Circular Wait: -Circular wait refers to the situation in which one or more processes wait for the resources they require in a circular order. We can eliminate the problem of circular wait by assigning priority numbers to each resource. A process cannot ask for a resource with a lower priority value. This ensures that no other process can request the resource being used by another process. Thus, there will never be a cycle.

After examining all of these factors, we discovered that there is one way to prevent deadlock. That is, a violation or circular wait.

Comments

Popular posts from this blog

What is Modular Programming? Where is it used?

What is Hibernate Framework?

Ellipse command in AutoCAD