Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

DEADLOCK & MEMORY MANAGEMENT, Study notes of Operating Systems

THIS TOPIC COVERED DEADLOCK,DELETION & RECOVERY SYSTEM OF COMPUTER OPERATING SYSTEM. THE STUDENTS CAN CLEAR THEIR CONCEPT OF OS HOW TO FUNCTION MULTIPLE OPERATIONS & HOW IT'S AFFECT OUR REGULAR WORK IN COMPUTER. THERE ARE ALSO MEMORY MANAGEMENT NOTES ALSO IT'S HELP HOW TO MANAGE THE MEMORY & HOW IT'S WORKS.

Typology: Study notes

2016/2017

Available from 03/10/2023

subhrajit-chakraborty
subhrajit-chakraborty 🇮🇳

5 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Deadlock detection
Detection mechanism of deadlocks for single instance of resource type and multiple
instance of resource type is different. We can detect the deadlocks using wait-for graph
for single instance resource type and detect using detection algorithm for multiple
instances of resource type.
Single Instance of resource type: single instance of resource type means, the system
consisting of only one resource for one type. We can detect this type of deadlocks with
the help of wait-for graph. A wait-for graph is a graph, it is derived from “Resource-
Allocation Graph”. It is consisting of only processes as vertices instead of, resources and
processes in resource allocation graph.
An edge from Pi to Pj in a wait-for graph implies that process Pi is waiting for
process Pj to release a resource that Pi needs. An edge Pi to Pj exists in a wait-for graph if and
only if the corresponding resource allocation graph contains two edges Pi to Rq and Rq to Pj for
some resource Rq.
pf3
pf4
pf5

Partial preview of the text

Download DEADLOCK & MEMORY MANAGEMENT and more Study notes Operating Systems in PDF only on Docsity!

Deadlock detection

  • Detection mechanism of deadlocks for single instance of resource type and multiple instance of resource type is different. We can detect the deadlocks using wait-for graph for single instance resource type and detect using detection algorithm for multiple instances of resource type.
  • Single Instance of resource type: single instance of resource type means, the system consisting of only one resource for one type. We can detect this type of deadlocks with the help of wait-for graph. A wait-for graph is a graph, it is derived from “Resource- Allocation Graph”. It is consisting of only processes as vertices instead of, resources and processes in resource allocation graph.

An edge from Pi to Pj in a wait-for graph implies that process Pi is waiting for process Pj to release a resource that Pi needs. An edge Pi to Pj exists in a wait-for graph if and only if the corresponding resource allocation graph contains two edges Pi to Rq and Rq to Pj for some resource Rq.

For example, consider the previous figure. We represent a RAG and corresponding Wait-for graph. A system is in deadlock state, if and only if the wait for graph contains cycles. So we can detect the deadlocks with cycles. In the figure there is 2 cycles one is P1 to P2 to P1. second one P2 to P3 to P2. so the system consisting of two deadlocks.

Deadlock detection –several instance of resource type:

  • The wait-for graph method is not applicable to several instance of resource type. So we need another method for this type that is “Deadlock Detection Algorithm”. This algorithm looks like “Banker’s Algorithm” and it employees several data structures that are similar to those used in the Bankers Algorithm. Data Structures: Available: A vector of length m indicates the number of available resources of each type. Allocation: An n x m matrix defines the number of resources of each type currently allocated to each process. Request: An n x m matrix indicates the current request of each process. If Request [ ij ] = k ,

then process Pi is requesting k more instances of resource type. Rj****.

Allocation Request Available A B C A B C A B C P 0 0 1 0 0 0 0 0 0 0 P 1 2 0 0 2 0 2 P 2 3 0 3 0 0 0 P 3 2 1 1 1 0 0 P 4 0 0 2 0 0 2 Sequence < P 0 , P 2 , P 3 , P 1 , P 4 > will result in Finish [ i ] = true for all i.

P 2 requests an additional instance of type C. Request A B C P 0 0 0 0 P 1 2 0 1 P 2 0 0 1 P 3 1 0 0 P 4 0 0 2

State of system? Can reclaim resources held by process P 0 , but insufficient resources to fulfill other processes; requests. Deadlock exists, consisting of processes P 1 , P 2 , P 3 , and P 4.

Recovery from Deadlock

There are two methods for breaking a deadlock. One solution is simply to abort one by one processes to break the circular wait. The second option is to preempt some resources from one or more of the deadlocked process.

Process Termination : it is one method to recover from deadlock. We use one of two methods for process termination, these are: Abort all deadlocked processes : It means release the all processes in the deadlocked state, and start the allocation from the starting point. It is a great expensive method. Abort one by one process until the deadlock cycle is eliminated : In this method first abort the one of the processes in the deadlocked state, and allocated the resources ( resource from abort process) to some other process in the deadlocked state then check whether the deadlock is breaked or not. If not abort another process from the deadlock state. Continue this process until we recover from deadlock. This method is less expensive than first.

Resource Preemption: there are three methods to eliminate deadlocks using resource preemption. These are: Selecting a Victim: Select a victim resource from the deadlock state, and preempt that one. Minimize cost. Rollback: Rollback the processes and resources unto some safe state, and restart it from that state. This method requires the system to keep more information about the state of all the running processes. Return to some safe state, restart process for that state.

Starvation: a process (or) a resources can be picked as a victim only a finite number of times, it is said to be starvation. The most common solution is to include the number of rollbacks in the cost factor. same process may always be picked as victim, include number of rollback in cost factor