December
1998 QUESTION 2 Total Marks: 20 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
2. | (a) With the aid of an example,
describe how deadlock can occur when two processes are competing for resources. |
[4] | |||||||||||||||||||||
Marks should be awarded on the following basis:
No marks should be awarded otherwise.
|
[4] | ||||||||||||||||||||||
(b) Name two
strategies which may be employed in handling deadlock. |
[2] | ||||||||||||||||||||||
One mark should be awarded for each valid point (up to a maximum of two marks). Examples include the following:
Other sensible answers should also receive credit.
|
[2] | ||||||||||||||||||||||
(c) Distinguish between the terms
job scheduler and CPU scheduler. |
[2] | ||||||||||||||||||||||
A
job scheduler is responsible for admitting jobs into the system (1 mark), whereas a CPU
scheduler allocates CPU time to jobs in the ready queue (1 mark). Other sensible answers should also receive credit.
|
[2] | ||||||||||||||||||||||
(d) Suppose, in a multiprogramming environment, a processor is assigned the following jobs for execution.
Priority is highest for 1 and lowest for 4. Draw a Gantt Chart to illustrate the execution of these jobs using the
following scheduling algorithms. |
[6] | ||||||||||||||||||||||
(i) First come first served. |
[1] | ||||||||||||||||||||||
Two marks should be awarded for a correct Gantt chart; one mark should be awarded if there is a minor slip in labelling; no marks should be awarded otherwise.
|
[2] | ||||||||||||||||||||||
(ii) Round robin, with a time quantum of 2. |
[2] | ||||||||||||||||||||||
Two marks should be awarded for a correct
Gantt chart; one mark should be awarded if there is a minor slip in labelling; no marks
should be awarded otherwise.
|
[2] | ||||||||||||||||||||||
(iii) Priority scheduling. |
|||||||||||||||||||||||
Two marks should be awarded for a correct Gantt chart; one mark should be awarded if there is a minor slip in labelling; no marks should be awarded otherwise.
|
[2] | ||||||||||||||||||||||
(e) For each of the algorithms mentioned in part (b), compute the
average waiting time. |
[6] | ||||||||||||||||||||||
(i) The
waiting time for 1 is 0, the waiting time for 2 is 1, the waiting time for 3 is 4, and the
waiting time for 4 is 9 (1 mark). Therefore, the average waiting time is 14/4 = 3.5 (1
mark).
|
[2] | ||||||||||||||||||||||
(ii) The
waiting time for 1 is 0, the waiting time for 2 is 1 + 4 = 5, the waiting time for 3 is 2
+ 4 + 2 = 8, and the waiting time for 4 is 3 + 4 + 2 = 9 (1 mark). Therefore, the average
waiting time is 22/4 = 5.5 (1 mark).
|
[2] | ||||||||||||||||||||||
(iii) The waiting time for 1 is 18, the waiting time for 2 is 8, the waiting time for 3 is 11, and the waiting time for 4 is 0 (1 mark). Therefore, the average waiting time is 37/4 = 9.25 (1 mark). | [2] | ||||||||||||||||||||||