×

Deadlock Avoidance

Deadlock Avoidance

In an operating system, for deadlock avoidance, we perform the following:

  • We only grant the request of the resources if the resulting state of the system will not cause any deadlock in the system.
  • We continuously check the state of the system, whether the system state is safe or unsafe.
  • It is a must that the process informs the operating system about the maximum resources it needs to finish its execution.
  • In the deadlock avoidance algorithm, we check the allocation of the resources to prevent from circular wait condition.
  • Even we can define the resource allocation state of the system with the help of the instances of the allocated resources to a process, available resources, and the maximum instance of the resources requested by the process to finish its execution.

The below table showed the state of a system that is recorded at a random time.

Resources Assigned

   Process  Type 1  Type 2   Type 3   Type 4
    A      0     1     4       1
    B      1     1     2       0
     C      2     0     1       0
    D      3     0     1       2

Resources Still Needed

   Process    Type 1   Type 2   Type 3   Type 4
       A       1      1       0        0
      B       0      1       1        2
       C       1      2       1        0
      D       2      1       1        2

I = (8 7 9 5)

J = (6 2 8 3)

K = (2 5 1 2)

In the above tables, we have used vector I, J, and K that define the resource allocation state of the system. The three vectors I, J, and K where:

‘I’ is used to determine the total instances of each resource in the system.

‘J’ is used to represent the instance of resources which we assigned to the processes.

'K' is used to determine the number of resources that are not in use.

In the system, we have four processes and four kinds of systems. Here, Table 1 contains the instances of each resource that are assigned to the processes, and Table 2 contains the resources which the processes still need.

Thus, when a system allocates all the requested resources to the processes without any deadlock occurrence, that system state is called a Safe State. When the system does not complete the resource request of the process, then we called it an Unsafe State.  

So, the key to deadlock avoidance is that if a process requests for any resource, then the request should be approved only if the resulting state is in a safe state.


Related Topics

DOS Operating System

What is DOS Operating System? An operating system that runs from a hard disk drive is known as the DOS (Disk Operating System).In other words, DOS (Disk Operating System) is defined...

7 minutes read.

Strategies for Handling Deadlock

Strategies for Handling Deadlock The Strategies for handling Deadlock are: Deadlock IgnoranceDeadlock PreventionDeadlock AvoidanceDeadlock Detection and Recovery Deadlock Ignorance Deadlock Ignorance is the most popular deadlock handling strategy. We can use this in the various operating systems for...

2 minutes read.

Multi-user Operating Systems

Introduction Since only one user may interact with the computer at any given time, the operating system we use on our personal computers, laptops, tablets, and phones is sometimes referred to...

8 minutes read.

Interested Variable Mechanism

Interested Variable Mechanism It is a must to provide progress to the process synchronization mechanism. In variable mechanism, if there is a process that doesn’t need to enter into the critical section, then due...

5 minutes read.

Operating System Properties

The Properties of Operating System are: Batch processingMultitaskingMulti-programmingInteractivityReal-Time SystemDistributed Environmentspooling 1. Batch Processing In Batch Processing, the OS first gathers the data and programs together in a batch, then processing starts. The operating system...

3 minutes read.

Scheduling Algorithms in OS

There are various types of scheduling algorithm which are used by the operating system to schedule the process on the processor. Objective of Scheduling Algorithms There are the following objectives of Scheduling Algorithms: Fare allocation...

2 minutes read.

Process Schedulers and Process Queue in OS

Process Schedulers There are various types of Process Schedulers: Long Term SchedulerShort Term SchedulerMedium Term Scheduler                                            Long Term Scheduler: - Long term scheduler is also referred to as Job Scheduler. The task of the Long-term...

3 minutes read.

Need of Operating System

There are various needs of operating system: Managing Input-Output UnitThe Operating system as a platform for application programsMultitaskingConsistent user interface Managing Input-Output Unit: - With the help of the operating system, the...

2 minutes read.

Test Set Lock Mechanism | Operating System

Modification in the Assembly Code The problem in the lock variable is that, in some cases, the process reads the previous or old value of the lock variable and enters into the critical...

4 minutes read.

Resource Allocation Graph in Operating System

Resource Allocation Graph in OS We use the resource allocation graph for the pictographic representation of the state of a system. The resource allocation graph contains all the information related to the processes that...

5 minutes read.

Can a Computer Run Without the Operating System

Computers may function right out of the box, mostly due to operating systems. Nowadays, there are probably already some pre-installed apps in a new computer when you buy one. Have...

9 minutes read.

FCFS Scheduling in OS

FCFS: First Come First Serve Scheduling in OS FCFS is a non-preemptive and preemptive scheduling algorithm that is easy to understand and use. In this, the process which reaches first is...

3 minutes read.

Advantages of Operating System

What is an Operating System?   An operating system is an interface that helps to communicate with the user and the computer hardware. Operating systems are used for file management, memory...

3 minutes read.

Difference between SSTF and LOOK Disk Scheduling Algorithm

Shortest Seek Time First / SSTF Shortest Seek Time First (SSTF) is an acronym for "shortest seek time first." The task request that is closest to the present position of the...

4 minutes read.

Bit Vector in Operating System

What is Bit vector? Bit vector is one of the most important methods used in the free space management of operating system. Free space management which is used by the operating...

3 minutes read.

Unix Operating System

Unix Operating System Unix Operating System is a multiuser, portable, time-sharing, and multitasking operating system that was developed in 1969. Unix operating system was developed by a group of AT &...

3 minutes read.

Round-Robin Scheduling Algorithm in OS

Round-Robin is a Preemptive Scheduling Algorithm and is the most commonly used algorithm in CPU Scheduling.In this, each Process is assigned with a fix time interval to execute, which is...

5 minutes read.

Operating System Services

The Operating System provides various types of services:   I/O operationProgram executionFile system manipulationCommunicationError HandlingResource allocationAccountingProtection 1. I/O Operation: - To execute a program, needs I/O, which consists of a file, or I/O device. Due to the protection...

3 minutes read.

Virtual Memory in Operating System

What is Virtual Memory Virtual Memory is a storage scheme in which the users have an illusion that users have a significant amount of Main Memory. We can perform this by taking a...

3 minutes read.

Difference between Protection and Security in Operating System

Some operating system mechanisms facilitate us to stop tampering with logical and physical resources. Some of these methods are security and protection. Protection and security are distinct concepts, despite the...

3 minutes read.