×

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

Lock Variable Mechanism | Operating System

Lock Variable Mechanism The Lock variable mechanism is a synchronization mechanism that is implemented in a user mode. It is a software procedure. Lock variable is a solution for busy waiting that can be...

3 minutes read.

What is Context Switching

Context Switching is the switching of CPU from one process to another process. Context switching means storing the process state so that we can reload the process when needed, and the execution...

3 minutes read.

Non-Contiguous Memory Allocation in Operating System

Memory is nothing but a storage space where various data are stored. We can store data in temporary and permanent memory as per our future requirements for data. We can...

9 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.

FCFS (First-Come-First-Serve) Disk Scheduling Algorithm

FCFS Disk Scheduling Algorithm FCFS (First-Come-First-Serve) is the easiest disk scheduling algorithm among all the scheduling algorithms. In the FCFS disk scheduling algorithm, each input/output request is served in the order...

4 minutes read.

Turn Variable or Strict Alternative Approach

Turn Variable or Strict Alternative Approach Turn Variable Approach is used for process synchronization mechanism, which offers synchronization between two processes. Turn variable is implemented on user mode, and it is a software mechanism. We...

3 minutes read.

Components of Operating System

Components of Operating System: An operating system is a complex and vast system. We can only create the operating system by dividing it into small parts. Each part must be...

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.

Difference between Seek Time and Disk Access Time in Disk Scheduling

Seek Time The time taken for the hard disk controller to detect a specific piece of recorded data is known as the seek time. The amount of time it takes to...

4 minutes read.

Commercial Mobile Operating Systems

Introduction to Commercial Mobile Operating Systems A computer program's common services are managed by an operating system (OS), which also handles computer hardware and software resources. The user can communicate with...

7 minutes read.

Thrashing in Operating System

A virtual memory system's poor performance when the same pages are loaded repeatedly due to a lack of main memory to store them in secondary memory is referred to as...

3 minutes read.

What is Deadlock in OS?

Deadlock in Operating System In an Operating System, a process uses various resources, and the resources are used in the following manner: Request the ResourceUse the ResourceRelease the Resource In the Operating System, Deadlock is a condition...

4 minutes read.

Operating System Tutorial

What is an Operating System? An Operating System is a System Software that handles the resources of a computer such as computer hardware and software and offers frequent services to the...

7 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.

Fixed Partitioning in Operating System

Fixed Partitioning in OS Fixed Partitioning is also known as Contiguous memory allocation. Fixed Partitioning is the easiest method, which is used to load more than one process into the main memory. In Fixed...

5 minutes read.

What is Scheduling on OS

Scheduling is the process which is used to share the computing resources such as memory, processor time, and bandwidth to the different processes, data flows, threads, and applications which need them. Scheduling is...

5 minutes read.

N-Step-SCAN Disk Scheduling

Before you study about N-Step-SCAN Disk Scheduling, it requires prerequisite of what is Disk Scheduling Algorithms: Operating systems use disc scheduling to schedule I/O requests that arrive at the disc....

4 minutes read.

Multitasking Operating Systems

An operating system is the fundamental piece of software that enables a computer system to function and execute a command as intended. The user interface, hardware, and every other piece...

7 minutes read.

File Access Methods in Operating System

File Access Methods in OS There are various types of file access methods in the operating system: Sequential Access MethodDirect Access MethodIndex Sequential Access Method Sequential Access Method: - Sequential Access Method is...

3 minutes read.

Trap vs Interrupt in Operating System

What is Trap in Operating System? A trap is a synchronous interrupt used to perform functionality when an error occurs in a user process. A trap in an operating system can...

4 minutes read.