Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

LAB # 08

Implementation of Deadlock Avoidance Banker’s Algorithm and study


about deadlock recovery

-> Assume that there are 5 processes, P0 through P4, and 4 types of resources. At T0 we
have The following system state:

Max Instances of Resource Type A = 03 (02 allocated + 1


Available) Max Instances of Resource Type B = 17 (12 allocated +
5 Available) Max Instances of Resource Type C = 16 (14 allocated
+ 2 Available) Max Instances of Resource Type D = 12 (12
allocated + 0 Available)

Given Matrices
Allocation Matrix Max Matrix Available MatrixNot
(No of the Max resources that may Allocated Resources
allocated be used bya process
resources by aprocess)
A B C D A B C D A B C D
P0 0 1 1 0 0 2 1 0 1 5 2 0
P1 1 2 3 1 1 6 5 2
P2 1 3 6 5 2 3 6 6
P3 0 6 3 2 0 6 5 2
P4 0 0 1 4 0 6 5 6
Total 2 12 14 12

Task#1. Create the need matrix (max-allocation).

Given Matrices
Safe Available Matrix Not Need Matrix
Sequence Allocated Resources (Max – Allocation)
A B C D A B C D
P0 1 5 2 0 0 1 0 0
1 6 3 0 0 4 2 1
P3 1 12 6 2 1 0 0 1
P1 2 14 9 3 0 0 2 0
P2 3 17 15 8 0 6 4 2
P4 3 17 16 12

Task#2. Use the safety algorithm to test if the system is in a safe state or not?
Task#3. Write the C# code of the given problem.

You might also like