Uploaded by overlordainz300

ECX5235 CAT1 2015 2016 MA

advertisement
THE OPEN UNIVERSITY OF SRI LANKA
DEPARTMENT OF ELECTRICAL & COMPUTER ENGINEERING
BACHELOR OF TECHNOLOGY
ECX5235 – OPERATING SYSTEMS
CAT 1 – 2015/2016
OPEN BOOK TEST
Time: 15:45 – 17:00 hrs
Date: 24th of July 2016
Answer all questions.
[Question 1]
Consider the following scenario which many processes compete for relatively few resources.
The operating system makes sure that all requested resources are available and allocated to a
process before moving the process to the READY queue. The system does not release these
recourses until the process is completed.
A list of available resources with the number of instances available and the possibility of
sharing among the processes are given below.
Resource No. of instances
Access
R1
2
Non sharable
R2
1
Sharable
R3
2
Non sharable
The following sequence of events has occurred when allocating the resources to perform a
function of a processor. “P” indicates a process and “R” indicates the resources.
Event
Action
Event
Action
1
P1 requests R2
8
P2 gets R2
2
P2 requests R1
9
P2 releases R2
3
P1 gets R2
10
P3 requests R1
4
P2 gets R1
11
P1 requests R3
5
P3 requests R2
12
P1 gets R3
6
P3 gets R2
13
P3 requests R3
7
P2 requests R2
a) Draw a directed resource graph to analyze the above scenario.
Page 1 of 3
[ Marks : 15]
b) Is this system, as a whole, deadlocked?
[ Marks : 10]
If “yes”, justify your answer.
If “not”, state which action next would cause a system deadlock. Justify your answer.
This system is not deadlocked. There’s no circular wait.
c) Illustrate the following four conditions by giving suitable examples for each from the
given scenario. Make appropriate assumptions.
[ Marks : 24]
i) Mutual exclusion : Only for non-sharable devices. Unless multiple devices
provided a resource cannot be shared by several processes.
ii) Resource holding: Holds a resource and waits for another to start or finish the
process.
iii) No preemption: Only the process holding a resource can release it.
iv) Circular wait :Cycle of waiting processes
d) State two ways to prevent “Resource holding”?
[ Marks : 10]
Page 2 of 3
First protocol: Each process requests and be allocated all of its resources before it begins
execution. This provision can be implemented by requiring that system calls requesting
resources for a particular process precede any other system calls.
Second protocol: A process requests resources only when it has none. A process may request
some resources and use them. Before it can request any additional resources, however, it must
release all the resources that it is currently allocated.
e) Is there a race condition in the given scenario? Justify your answer.
[ Marks : 10]
No. In the scenario it has specified that the operating system makes sure that all
requested resources are available and allocated to a process before moving the process to
the READY queue.
f) Distinguish deadlock, starvation and race. Explain using a suitable example.
[Marks : 21]
Please refer the course materials.
g) State at least two assumptions that you made when answering the above questions.
[Marks : 10]
Please refer the course materials.
Page 3 of 3
Download