The Superior College, Lahore: Assignment-III - BSSE (Spring 2021)
The Superior College, Lahore: Assignment-III - BSSE (Spring 2021)
Question 1 (5 marks)
Apply multi-level queue scheduling on the following processes. Priority of queue1 is greater
than queue2. Queue1 uses round robin (Q=2) and queue2 uses FCFS. Draw the gantt chart
for it.
processes Arrival time Burst time Queue #
P1 0 4 1
P2 0 3 1
P3 0 8 2
P4 10 5 1
Ans:
P1 P2 P1 P2 P3 P4 P3
0 2 4 6 7 10 15 20
Max Allocation
Processes A B C A B C
P0 7 5 3 0 3 0
P1 3 2 2 2 0 0
P2 9 0 2 3 0 2
P3 2 2 2 2 1 1
P4 4 3 3 0 0 2
Ans :
Banker’s algorithm
Now we check if each type of resource request is available for each process.
Need <= Available
If condition is true than we use
(New available = available + Allocation) this condition
Max Allocation Need Available
Processes A B C A B C A B C A B C
P0 7 5 3 0 3 0 7 2 3 3 1 2
P1 3 2 2 2 0 0 1 2 2 5 1 2
P2 9 0 2 3 0 2 6 0 0 7 2 3
P3 2 2 2 2 1 1 0 1 1 7 5 1
P4 4 3 3 0 0 2 4 3 1 10 2 5
Question 3 (5 marks)
Determine if there is a deadlock in the graph. Explain why or why not.
Ans:
In this graph dead lock exists because a cycle become exists in the graph. If the cycle is not exist
in graph mean deadlock exist in graph and if in graph cycle is exist mean deadlock may or may
not be exist.
R1 assigned to p1 but p1 request to R3
R1 assigned to P2 but request to R3 same time P1 request to R4. Already P1 assigned and
request to himself so R4 will wait until proceeds 1 terminate
P3 request to R1 but wait occur to due to the previous process same time R4 request to P3 and P3
assigned to R2, R1 will be wait until P3 terminate
Whenever P3 request to R2 same time R2 assigned himself to P4, therefore P3 will wait and R5
also assigned himself to p4..so all process is busy no process is to be alone because all process is
bust no process is released to any process all are in request state or in assigned state.