Deadlock is a situation that occurs in a computer system when two or more processes are unable to proceed because each is waiting for the other to release a resource. Deadlocks can cause a system to become unresponsive and can lead to resource wastage. There are two approaches to dealing with deadlocks: prevention and avoidance. Deadlock prevention involves designing a system in such a way that deadlocks cannot occur, while deadlock avoidance involves dynamically managing the allocation of resources to prevent deadlocks from occurring.

Difference between Deadlock Avoidance and Deadlock Prevention

Deadlock avoidance differs from deadlock prevention in that it allows a system to allocate resources dynamically while still preventing deadlocks from occurring. The Deadlock prevention, on the other hand, requires the system to be designed in such a way that deadlocks cannot occur in the first place. The Deadlock prevention techniques include resource ordering, deadlock detection, and avoidance of circular wait conditions. Deadlock avoidance algorithms, on the other hand, use a more dynamic approach to managing resource allocation.

Deadlock Avoidance Algorithm

One of the most common algorithms for deadlock avoidance is the Banker’s algorithm. The Banker’s algorithm is a resource allocation algorithm that is used to prevent deadlocks from occurring in a system. It works by allowing a system to allocate resources only if the allocation does not result in a deadlock. The algorithm uses a series of checks to determine whether a resource allocation is safe or not.

The Banker’s algorithm is based on the following three concepts

Available Resources

The system maintains a list of available resources, which represents the number of instances of each resource that are available.

Maximum Resource Requirement

Each process in the system specifies the maximum number of instances of each resource that it may need.

Currently Allocated Resources

The system maintains a list of currently allocated resources, which represents the number of instances of each resource that are currently allocated to each process.

The Banker’s algorithm works by using these three concepts to determine whether a resource allocation is safe or not. It does this by simulating the allocation of resources to each process and checking whether the allocation can result in a deadlock. The algorithm works as follows:

  • When a process requests a resource, the system checks whether the allocation can be made without causing a deadlock. It does this by simulating the allocation of resources to each process and checking whether the resulting system state is safe.
  • If the allocation is safe, the resources are allocated to the process. If the allocation is not safe, the process is blocked until the resources become available.
  • When a process releases a resource, the system updates the available and currently allocated resources lists.
  • If a deadlock is detected, the system uses a recovery mechanism to resolve the deadlock.

The Banker’s algorithm works by preventing deadlocks from occurring in a system. It does this by ensuring that a resource allocation is safe before it is made. If the allocation is not safe, the process is blocked until the resources become available. The algorithm is effective in preventing deadlocks but can be resource-intensive, as it requires the system to simulate resource allocation for each process.


OS-2022

Q-1.

(a) Write are the functions of operating systems? write a note on multi programmed operating systems ?

(b) Distinguish between client server and peer to peer model of distributed systems .

Q-2.

(a) With a Neat Sketch, Describe the services that an Operating System provides to users, processes and other systems.

(b) What is meant by Storage Structure? Discuss Storage Hierarchy.

(c) Write the Advantages and Disadvantages of using the same system call interface for manipulating both Files and Devices.

Q-3.

(a) What are the criteria for evaluating the CPU scheduling algorithms? Why do we need it?

(b) Define process. Explain various steps involved in change of a process state with process state neat transition diagram.

Q-4.

(a) What is synchronization? Explain how semaphores can be used to deal with n-process critical problem.

(b) Define a thread. Give the benefits of multithreading. What resources are used when a thread is created?

Q-5.

(a) How dose deadlock avoidance differ from deadlock prevention? Write about deadlock avoidance algorithm in detail.

(b) Different between external fragmentation and internal fragmentation. How to solve the fragmentation using paging?

Q-6.

(a) What is the purpose of paging the page table? Consider the following page reference string 1,2,3,4,5,1,2,3,4,5 for a memory with three frames. How many page faults would LRU and FIFO replacement algorithm?

(b) What are the disadvantages of single contiguous memory allocation? Explain.

Q-7.

(a) Briefly explain about single-level, two-level and three Structured directories.

(b) What is disk scheduling? Explain the C-SCAN scheduling by giving an example.

Q-8.

(a) Interrupt and spooling.

(b) UNIX file system.

(c) Program and system threats.

JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.