0% found this document useful (0 votes)
65 views7 pages

Comp3101 18122017

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views7 pages

Comp3101 18122017

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

THE UNIVERSITY OF THE WEST INDIES

Semester I • Semester II o Semester Ift


Examination of December 201'
Originating Campus: Cave Hill LI Mona U St. Augu: tine 0 Open 701

Mode: On Campus U By Dista ice 0

Course Code and Title: COMP3101 - Operating Systems

Date: December 18, 2017 Time:4:00 PM - 6:00 PM

Duration 2 Hours Paper No: 1

Materials required:
Answer booklet: Normal U Special LII Not required Eli]
Calculator: Programmable 0 Non Programn able U Not required LI
(where applicable)

Multiple Choice
answer sheets: numerical LI alphabetical 0 1-20 111 -100 0

Auxiliary/Other material(s): None

Instructions to Candidates: This paper has SEVEN (7) page; and Five (5) questions

Candidates are reminded that the examiners shall take into account the proper use of the
English Language in determining the mark for each response.

Answer QUESTION ONE (1) and any other THREE (3) questio is.
Answer each section and question in a SEPARATE page.

The maximum number of marks you may earn for the entire i aper is 50. The number in [] by
each question indicates the number of marks allotted to the qt estion. Justify all your answers;
full credit will be given to any supported answers, partial credi: will be given where applicable.
Good luck!!!

0 The University of the West Indies Course Code COMP3 101 2017/ .......... / ...... — ..
ii) Assume that at time 5 no system resources are being used except for the processor
and memory. Now consider the following events: In Time = 22: The P5 and P8 are
in the ready/running state, and the
At time 5: P1 executes a command to read from disk unit 3. P1, P3, P7 are into the block state
for Input/output.
At time 15: P5's time slice expires.
At time 18: P7 executes a command to write to disk mit 3. In Time = 37: The P1, P3, P8 are
At time 20: P3 executes a command to read from disK unit 2. in the ready/running state, P5 is in
At time 24: P5 executes a command to write to disk i tnit 3. the block state. It suspends or
At time 28: P5 is swapped out. swapped out, and P7 is on the
block state for Input/output.
At time 33: An interrupt occurs from disk unit 2: P3': read is complete.
At time 36: An interrupt occurs from disk unit 3: P1' read is complete.
In Time= 47: The P1, P3, and P5
At time 38: P8 terminates. are in the ready/running state, P7
At time 40: An interrupt occurs from disk unit 3: P5' write is complete.
is on the block state for
At time 44: P5 is swapped back in. Input/output, and P8 is in the exit
At time 48: An interrupt occurs from disk unit 3: P7's write is complete.
state.
For each time 22, 37, and 47, identify which state eac h process is in. If a process is
blocked, further identify the event on which is it blocKed.

[3 marks]

Q2 [10 marks]

a) i) Consider the following program;


P1; { P2:
shared mt x; shared mt x;
X=10; X=10;
while (1) { while (1) {
X=X-1; XX—.;
x=x+ 1; X=X+ 1;
if(X != 10) if(X != 10)
printf ("X is %d", X) printf "X is %d"

} }
} I
Note that the scheduler in a uniprocessor system would implement pseudo-parallel
execution of these two concurrent processes by inter eaving their instructions without
restriction on the order of the interleaving. Show a equence, such that the statement
"X is 10" is printed
[2 marks]

ii) Consider a version of the bakery algorithm without the variable choosing. Then we
have

1. mt number [n];
2. while (true)(
3. number[i] = 1 + getmax(number[], n);
4. for (mt j=0; j<n; j++) {
0 The University of the West Indies Course Code COMP3 101 2017/ .......... /
5. While ((number[j] !=O) && (number[j], j) < (number[i], i)) { }
6.
7. / critical section
8. Number [i] =0;
9. / remainder
10. 1

Does this version violate mutual exclusion? Explain why or why not. [3 marks]

b) i) List three control problems associated with competing processes and briefly define
them. What operations can be performed on a semaphore? Mutual exclusion [2 marks]
starvation, deadlock
ii) Consider an environment in which there is a one-to-one mapping between user-level
threads and kernel-level threads that allows one or more threads within a process to
issue to issue blocking system calls while other threads continue to run. Explain why
this model can make multithread programs run faster than their single-threaded
counterparts on a uniprocessor computer
[3 marks]
The issue here is that a program spends much of its time waiting for I/O to complete. In a
multithreaded program, one KLT can makethe blocking system call, while the other KLTs can
continue to run. On a uniprocessor machine, a process that would otherwise have to block for
Q3 [10 marks] all thesecalls can continue to run its other threads.

a) i) Given the following state for the Banker's Algorithm. 6 processes P0 through P5. 4
resources types: A (15 instances); B (6 instances); C (9 instances); D (10 instances).
Snapshot at time TO:
Available
A B C D
16 13 IS 14 I

Current allocation Maximum demand


Process
PO
PI

Calculate the Need matrix and show that the current state is safe. [3 marks]

ii) The following state transition table is a simplified model of process management, with
the labels representing transitions between states of READY, RUN, BLOCKED, and
NONRESIDENT.

© The University of the West Indies Course Code COMP3 101 -- -


READY RUN B! OCKED NONRESIDENT

READY - 1 - 5

RUN 2 - 3 -

BLOCKED 4 - - 6

Give an example of an event that can cause each of the above transitions. Draw a
diagram if that helps [2 marks]

b) i) Consider the following workload

Process Burst Time Priority Arrival Time

P1 50 ms 4 0 m

P2 20 ms 1 20 ms

P3 100 ms 3 40 ms

P4 40 ms 2 60 ms

Show the schedule using the "Shortest Remaining Fime", non-preemptive priority
and "Round-Robin" with quantum 30 ms. [3 marks]

ii) What is the difference between preemptive and non-preemptive scheduling? Briefly
explain the round robin scheduling algorithm
[2 marks]

Q4 [10 marks]

a) i) Why is the average search time to find a record .n a file less for an indexed sequential
file than for a sequential file? Hence, define three file allocation methods [2 marks]

ii) What is the difference between passive and actil e security threats? What is the role of
encryption in the operation of a virus? [2 marks]

b) i) The question arises as to whether it is possible t develop a program that can analyze a
piece of software to determine if it is a virus. Co isider that we have a program D that is
supposed to be able to do that. That is, for any program P, if we run D(P), the result is
TRUE (P is a virus) or FALSE (P is not a virus). Now consider the following program:

flflklfl2IflI nfl.? I I
Program CV :=
{...
main-program :
{ if D (CV) then goto next
else infect-executable;

next:

In the preceding program determine if D can correctly decide whether CV is a


virus
[3 marks]

ii) What are the classes of real-time scheduling algorithm and what is the difference
between logical 110 and device I/O
[3 marks]

Q5 [10 marks]

a) Suppose the page table for the process currently executing on the processor looks like the
following: All numbers are decimal, everything is numbered starting from zero and all
addresses are memory bytes addresses. The page size is 1,024 bytes

Virtual page Valid bit Reference bit Modify bit Page frame
number number

0 1 1 0 4

1 1 1 1 7

2 0 0 0 -

3 1 0 0 2

4 0 0 0 -

5 1 0 1 0

Describe exactly how, in general a virtual address generated by the CPU is translated into a
physical main memory address. What physical address, if any, would the virtual addresses
1,052, and 2,221 correspond to?
[3 marks]

b) i) Directories can be implemented either as "special files" that can only be accessed in
limited ways or as ordinary data files. What are the advantages and disadvantages of each
approach? [3 marks]
Let a be the percentage of a program code that Ca; L be executed simultaneously by n
computers in a cluster, each computer using a dii ferent set of parameters or initial
conditions. Assume that the remaining code must b executed sequentially by a single
processor. Each processor has an execution rate of x YIIPS.

Derive an expression for the effective MIPS rate when using the system for
exclusive execution of this program, in terms of i, a and x.
If n = 16 and x = 4 MIPS, determine the va ue of a that will yield a system
performance of 40 MIPS
[4 marks]

End of Question Paper

You might also like