UNIVERSITI TEKNOLOGI MALAYSIA
SCR 2043 – Tutorial on Deadlock Module
1. Consider the traffic deadlock depicted below
a) Show that the four necessary conditions for deadlock indeed hold in this example.
b) State a simple rule that will avoid deadlocks in this system.
2. a) What are the necessary conditions fro a deadlock to occur? Elaborate your
answer.
b) When is a system in a safe state?
3. We can have deadlock detection methods and also deadlock avoidance mechanisms. How
would a deadlock avoidance mechanism run?
(i). What are the advantages of a deadlock avoidance mechanism?
(ii). What are the disadvantages of a deadlock avoidance mechanism?
4. Refer to the following diagram, describe the relationship between the circles, squares and
directed lines that represent the Resource Allocation Graph.
5. Given process resource usage and availability as described in Table 1.
Table 1
Process Current Outstanding Resources
Allocation Requests Available
A B C A B C A B C
P1 2 0 0 1 1 0 0 0 0
P2 3 1 0 0 0 0
P3 1 3 0 0 0 1
P4 0 1 1 0 1 0
a) Draw the resource allocation graph.
b) Is the system in a deadlock state? Answer the question using the
following techniques:
i. By viewing the RAG. Draw the reduced resource allocation graph if it
is possible to reduce.
ii. Detection algorithm.
6. For each of the following question determine whether a system is in a safe state or not.
Question 1 Question 2 Question 3
Name Allocated Max Allocated Max Allocated Max
Andy 0 6 1 6 1 6
Barbara 0 5 1 5 2 5
Marvin 0 4 2 4 2 4
Suzanne 0 7 4 7 4 7
Available 10 2 1
7. Consider the following system with 5 processes, P0 through P4 and four resource types,
A,B,C,D. At time T0, the following snapshot of the system was taken:
Process Allocation Max Available
ABCD ABCD ABCD
P0 3011 5023 0211
P1 1200 2200
P2 5310 5320
P3 0142 0272
P4 3250 3361
Use the Bankers’ algorithm to answer the following questions.
(i) Calculate the total number of resource for type A, B, C and D.
(ii) What is the content of the matrix Need, which stores the number of resources still
needed by each process?
(iii) Is the system in a safe state? Show a safe sequence, if one exists.
(iv) If a request from process P1 arrives for an additional 2 instances of resource type
B and one of resource type D, can this request be granted immediately? Illustrate.
8. Consider the following system with 3 processes, P0 through P2 and three resource types,
which are A,B and C. At time T0, the following snapshot of the system was taken:
Max Allocation Need Available
ABC ABC ABC ABC
P0 523 212 311 422
P1 416 102 314
P2 636 323 313
(i) Is the system in a safe state? Show a safe sequence, if one exists.
(ii) Assume P1 request (2, 1, 2).
Should the system satisfy the request of P1?
Illustrate in details.
(iii) Assume P1 returns back the resources in (ii) i.e. (2, 1, 2), and P2 request (1, 0, 1).
Should the system satisfy the request of P1?
Illustrate in details