操作系统代写 | COMP2006 Operating Systems

本次澳洲代写主要为操作系统相关的限时测试

QUESTION ONE (total: 20 marks): Deadlock

a) (4 marks). The three overall strategies in handling deadlocks are (i) Ensure the system
will never enter a deadlock state, (ii) Allow deadlocks, but device schemes to recover
from them, and (iii) Pretend deadlock does not happen. Among the three strategies,
which one requires the least overhead? Which one uses the most overhead? Explain your
answers.

b) (3 marks). Is the following statement true or false? Justify your answer.

Deadlocks can always be detected by finding a cycle in a resource allocation graph.

c) (4 marks). Discuss two main factors to decide when to invoke a deadlock detection
algorithm.
Answer:

d) (Total: 9 marks). Consider the following snapshot of a system that contains five
processes {P0, P1, P2, P3, P4} and four types of resources {A, B, C, D}. The
information about the system’s total available resources, the maximum demand of each
process, and the current allocation of resources are as shown.
Available
A B C D
8 5 9 7
Current Allocation
A B C D
P0 1 0 1 1
P1 0 1 2 1
P2 4 0 0 3
P3 1 2 1 0
P4 1 0 3 0
Answer the following questions using the banker’s algorithm:
(i) (2 marks). Calculate the Need matrix.
(ii) (3 marks). Is the system in a safe state? If so, show its safe sequence. Otherwise
state which processes are in deadlock.
(iii) (4 marks). Can a request of one instance of resource A by Process P0 be granted
according to the banker’s algorithm? Show the details for the decision.
Maximum Demand
A B C D
P0 3 2 1 4
P1 0 2 5 2
P2 5 1 0 5
P3 1 5 3 0
P4 3 0 3 3

(i) Need matrix

Needs
A B C D
P0

(ii) Is the system safe?