(a) What are the three steps involved
in the resource utilization sequence? [3]
Request the resource (1 mark); use the resource
(1 mark); release the
resource (1 mark). [3 marks]
(b) Describe the following deadlock conditions: [2]
(i) Hold and wait
(ii) Circular wait
(i) One process already holds at least one
resource and is waiting to
acquire more resources which are currently held by other processes
(1 mark).
(ii) There is a circular chain of two or more processes, each of which
is waiting for a resource held by the next member of the chain (1
mark). [2 marks]
(c) If deadlock occurs, one way of recovering from it is via rollback.
Describe this method. [2]
Periodic checkpoints are made on each process,
with the status at each
checkpoint being written to a file (1 mark). When a deadlock is detected
the process that holds the required resource is rolled back to the
previous checkpoint (1 mark).
Other correct answers should also receive credit. [2 marks]
(d) How does Banker's algorithm work for a single resource? In your
description,
give one example of a safe state and one example of an unsafe state.
[4]
Bankers algorithm considers each request
for a resource as it occurs and checks if granting that resource will
lead to a safe or an unsafe state (1 mark). If granting the resource
will lead to an unsafe state, then the request is postponed (1 mark).
A further mark should be awarded for a satisfactory illustration of
a safe state and another further mark should be awarded for a satisfactory
illustration of an unsafe state. [4 marks]
(e) Describe how the following conditions for deadlock may be prevented:
[4]
(i) Hold and wait
(ii) Circular wait
(i) Here, deadlock may be prevented by ensuring
that a process waiting for a resource does not hold any resources
(1 mark). For example, it might be ensured that a process acquires
all the resources it needs before starting execution (1 mark). Other
correct answers should also receive credit.
(ii) Here, a numbering scheme for resources can be enforced (1 mark)
such that resources are ordered linearly ensuring that requests are
made in numerical order (1 mark). Other correct answers should also
receive credit. [4 marks]
|