0% found this document useful (0 votes)
311 views9 pages

Introduction To Banker's Algorithm

The document introduces Banker's Algorithm, which includes data structures like Available (resources available), Max (maximum request), Allocation (current allocation), and Need (remaining need). It describes the Safety Algorithm which checks if a process can request resources in a safe state. The Resource-Request Algorithm is also described, which pretends to allocate resources to a process if it is safe, and restores the previous allocation if unsafe. An example with 5 processes and 3 resource types is provided.
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)
311 views9 pages

Introduction To Banker's Algorithm

The document introduces Banker's Algorithm, which includes data structures like Available (resources available), Max (maximum request), Allocation (current allocation), and Need (remaining need). It describes the Safety Algorithm which checks if a process can request resources in a safe state. The Resource-Request Algorithm is also described, which pretends to allocate resources to a process if it is safe, and restores the previous allocation if unsafe. An example with 5 processes and 3 resource types is provided.
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/ 9

Constants:

______________________________________________
• Introduction to Bakery Algorithm
• Data structures for Banker’s Algorithm
• Safety Algorithm for Banker’s Algorithm
• Resource-Request Algorithm
• Working Example
Introduction to Banker’s Algorithm

• Multiple Instances
• System has no limited resources
• Advance claim for max resource allocation
• When a process gets all its resources it must return
them in a finite amount of time
Data Structures for 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 resources type available.
Max: n * m matrix. If Max [i,j] =k, then process may request at most k instances of resources type .
Allocation : n*m matrix. If allocation[i,j] =k then is currently allocated k instances of .
Need: n*m Matrix. If Need[i,j] =k then may need k more instances of .
to complete its task.
Need[i,j] =Max[i,j] – Allocation [i,j]
Finish: Boolean value, either true or false, if finish[i] = true for all I return safe else unsafe.
Safety Algorithm
__________________________________________

1.Let Available and Finish be vectors of length m and n,


respectively. Intialize Finish [i] = false for i=0,1,2,3,n-1
2.Find an I such that both
(a) Finish [i] =false (b) < Available
If no such I exists, go to sleep
Safety Algorithm
___________________________________________________

3. Available = Available +
finish[i] = true
Goto step 2
4.If Finsih [i] == true for all i , then system is in a safe
state.
Resource-Request Algorithm
___________________________________________________

• = request vector for process . If then process wants k


instances of resource type .
1.If = go to step 2.otherwise rasie error condition, since
process has exceeded its maximum claim
2.if < Available, go to step 3. Otherwise must wait,
since resources are not available
Resource-Request Algorithm
_________________________________________

3.Pretend to allocate requested resources to by modifying the state as


follows:
Available = Available -
= +;
=
If safe resources are allocated to
If unsafe must wait, and the old resource allocation state is restored.
Working Example of Banker’s Algorithm
_________________________________________
• Considering a system with five processes P0 through P4 and three
resources of type A, B, C. Resource type A has 10 instances, B has 5
instances and type C has 7 instances. Suppose at time t0 following
snapshot of the system has been taken.
Working Example of Banker’s Algorithm
_____________________________________
Solution:

You might also like