An operating system uses the Banker’s algorithm for deadlock avoidance when managing the
allocation of four resource types A, B, C and D to four processes P1, P2, P3 and P4. Resource
type A has 6 instances, B has 4 instances, type C has 3 instances and type D has 3 instances. The
table given below presents the current system state. Here, the allocation matrix shows the current
number of resources of each type allocated to each process and the Max matrix shows the
maximum number of resources of each type required by each process during its execution.
Available Allocation Max Processe
s
D C B A D C B A D C B A
1 1 1 1 1 1 1 1 2 1 2 2 P0
0 0 1 1 0 1 1 1 P1
1 1 0 3 1 1 1 4 P2
0 0 1 0 2 0 2 0 P3
Answer the following questions considering the above case study:
Need matrix = max – allocation
Processes A B C D
P0 1 1 0 1
P1 0 0 1 0
P2 1 1 0 0
P3 0 1 0 2
Now P3 will be executed
Available [new ]= available of P2 + Allocation p3
6333 + 01 00
=6433
It is safely executed
Safe state sequence = P0 P1 P2 P3
To Examine the safe state of the system in case of serving REQ1 and REQ2, independently.
Max of P0 = Max A + REQ P0
2 2 1 2 + 1 0 1 0
= 3 2 2 2
Need P0 = max P0 – available
= 3 2 2 2 – 1 1 1 1
= 2 1 1 1
need > available
P0 is rejected
max P1 = max A + REQ P1
1 1 1 0 + 0 0 1 1
= 1 1 2 1
need of P1 = max P1 – allocation
= 1 1 2 1 – 1 1 1 1
= 0 0 1 0
REQ1: P0 requests 1 units of A, 0 units of B, 1 units of C and 0 units of D
REQ2: P1 requests 0 units of A, 0 units of B, 1 units of C and 1 units of D
P1 is in safe state
Collaboration and assignment rules
The work must be all your own. Do not copy any parts of any of the assignments from anyone.
Do not make any parts of your assignments available to anyone, and make sure none can read
your files. The university policies on academic integrity will be applied rigorously. The Turnitin
system will be used to check the similarity of the assignment and the acceptable similarity is
15% ONLY. The total mark of this assignment is 20% of the total course work. Upload your
assignment to the Moodle system of Ahlia University before the indicated deadline date.
Assessment Rubric:
Assessment ILOs Mark
Q1 B1 4
Q2 B1 4
Q3 B1 4
Q4 B2 4
Discussion & presentation D1 2
Handing over the assignment on
Time
D3 2
Total: 20 marks