0% found this document useful (0 votes)
9 views14 pages

Lecture3 Deadlock

The document outlines key concepts related to deadlock avoidance algorithms in operating systems, specifically focusing on the Resource Allocation Graph scheme and Banker's Algorithm. It details the conditions under which processes can request resources and the necessary data structures for implementing these algorithms. Additionally, it explains how to determine deadlock situations through resource allocation graphs.

Uploaded by

bca2m2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views14 pages

Lecture3 Deadlock

The document outlines key concepts related to deadlock avoidance algorithms in operating systems, specifically focusing on the Resource Allocation Graph scheme and Banker's Algorithm. It details the conditions under which processes can request resources and the necessary data structures for implementing these algorithms. Additionally, it explains how to determine deadlock situations through resource allocation graphs.

Uploaded by

bca2m2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

INSTITUTE OF INFORMATION TECHNOLOGY & MANAGEMENT

Accredited ‘A’ Grade by NAAC &Recognised U/s 2(f) of UGC act


Rated Category `A+’ by SFRC & `A’ by JAC Govt. of NCT of Delhi
Approved by AICTE & Affiliated to GGS Indraprastha University, New Delhi

Operating System & linux

BCA
Semester: V
Paper code:-BCA 301

© Institute of Information Technology and Management, D-29, Institutional Area, Janakp


uri, New Delhi-110058
List of Topics

• Deadlock Avoidance algorithms:-


• Resource Allocation Graph scheme
• Banker's Algorithm
• Safety Algorithm

© Institute of Information Technology and


© Institute of Information
Management, D-29, Institutional
Technology
Area,and
Janakpuri,
Manage
ment, D-29, Institutional
New Delhi-110058 Area, Janakpuri, New Delh
i-110058
Deadlock Avoidance Algorithms

• Single instance of a resource type


• Use a resource-allocation graph
• Multiple instances of a resource type
• Use the banker's algorithm

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Resource-Allocation Graph Scheme

• Claim edge P; → R, indicated that


process P; may request resource
R;;represented by a dashed line.
• Claim edge converts to request edge
when a process requests a resource.
• Request edge converted to an
assignment edge when the resource is
allocated to the process.
• When a resource is released by a
process,
© Institute of Informationassignment edge reconverts to
Technology and Management, D-29,

a claim edge.
Institutional Area, Janakpuri, New Delhi-110058
© Institute of Information Technology and Management, D-29,
Institutional Area, Janakpuri, New Delhi-110058
© Institute of Information Technology and Management, D-29,
Institutional Area, Janakpuri, New Delhi-110058
Banker's Algorithm

• Multiple instances.
• Each process must a priori claim maximum use.
• When a process requests a resource it may have to
wait.
• When a process gets all its resources it must return
them in a finite amount of time.

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Data Structures for the Banker's Algorithm

Let n = number of processes, and m = number of resources types.


• Available: Vector of length m. If available [j] = k, there are k
instances of resource type R, available
• Max: n x m matrix. If Max [i,j] = k, then process P, may request at
most k instances of resource type Rj
• Allocation: n x m matrix. If Allocation[i,j] = k then P, is currently
allocated k instances of Rj
• Need: n x m matrix. If Need[i,j] = k, then P, may need k more
instances of R, to complete its task

need [i,j] = Max[i,j] - Allocation [i,j]

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Safety Algorithm

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Resource-Request Algorithm for Process Pi

Resource-Request Algorithm for Process Pl


request vector for process Pi. If Request i [j] = k then
process Pi wants k instances of resource type Rj
l. If Requesti <= Needi go to step 2. Otherwise, raise error condition, since
process has exceeded its maximum claim
2. If Requesti <= Available, go to step 3. Otherwise Pi must wait, since
resources are not available
3. Pretend to allocate requested resources to Pi by modifying the state as
follows:
Available = Available – Request i;
Allocationi = Allocation i + Request i;
Need i = Need i – Request i;
If safe -> the resources are allocated to Pi
If unsafe -> Pi must wait, and the old resource-allocation state is restored
© Institute of Information Technology and Management, D-29,
Institutional Area, Janakpuri, New Delhi-110058
Example of a Resource Allocation Graph

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Resource Allocation Graph With A Deadlock

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Graph With A Cycle But No Deadlock

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058
Basic Facts

• If graph contains no cycles no deadlock


• If graph contains a cycle
• if only one instance per resource type, then deadlock.
• if several instances per resource type, possibility of
deadlock.

© Institute of Information Technology and Management, D-29,


Institutional Area, Janakpuri, New Delhi-110058

You might also like