You are on page 1of 16

CS311: Operating Systems

Faculty of Science, Technology and Environment


School of Computing, Information and Mathematical Sciences

Final Examination
Semester 1 2017

F2F Mode

Duration of Exam: 3 hours + 10 minutes

Reading Time: 10 minutes

Writing Time: 3 hours

Total Marks: 100

Instructions:

Answer all questions in this paper

This exam is worth 50% of your overall mark

The minimum mark to pass the final exam is 40/100

The total number of pages including this cover sheet is 16

This is a closed book exam

Page 1 of 16
Section A: Multiple Choice [10 Marks]
Circle the letter of the correct answer for Questions 1-10 in the grid provided below. Each question has
only one correct answer and is worth 1 mark each.

1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
8 A B C D
9 A B C D
10 A B C D

1) The major difficulty in designing a layered operating system approach is ____.


A. appropriately defining the various layers
B. making sure that each layer hides certain data structures, hardware, and operations
from higher-level layers
C. debugging a particular layer
D. making sure each layer is easily converted to modules

2) A message passing model is ____.


A. easier to implement than a shared memory model for intercomputer communication
B. is faster than the shared memory model
C. a network protocol and does not apply to operating systems
D. is only useful for small simple operating systems

3) When a child process is created, which of the following is a possibility in terms of the
execution or address space of the child process?
A. The child process runs concurrently with the parent.
B. The child process has a new program loaded into it.
C. The child is a duplicate of the parent.
D. All of the above

4) Which of the following would be an acceptable signal handling scheme for a multithreaded
program?
A. Deliver the signal to the thread to which the signal applies.
B. Deliver the signal to every thread in the process.
C. Deliver the signal to only certain threads in the process.
D. All of the above

Page 2 of 16
5) A deadlocked state occurs whenever ____.
A. a process is waiting for I/O to a device that does not exist
B. the system has no available free resources
C. every process in a set is waiting for an event that can only be caused by another process
in the set
D. a process is unable to release its request for a resource after use

6) Suppose we are operating with execution-time binding and the physical address generated
is 300. The relocation register is set to 100. What is the corresponding logical address?
A. 199
B. 201
C. 200
D. 300

7) A microkernel is a kernel ____.


A. containing many components that are optimized to reduce resident memory size
B. that is compressed before loading in order to reduce its resident memory size
C. that is compiled to produce the smallest size possible when stored to disk
D. that is stripped of all nonessential components

8) Which of the following is an example of a systems program?


A. Command interpreter
B. Text formatter
C. Database systems
D. Web browser

9) The list of processes waiting for a particular I/O device is called a(n) ____.
A. standby queue
B. device queue
C. ready queue
D. interrupt queue

10) ____ is a thread library for Solaris that maps many user-level threads to one kernel thread.
A. Pthreads
B. Green threads
C. Sthreads
D. Java threads

Page 3 of 16
Section B: Short Answer [90 Marks]

1) There are two different ways that commands can be processed by a command interpreter. One
way is to allow the command interpreter to contain the code needed to execute the command.
The other way is to implement the commands through system programs. Compare and contrast
the two approaches. [4 marks]

2) Explain why a modular kernel may be the best of the current operating system design
techniques. [3 Marks]

3) Explain how segmentation memory management scheme differs from paging memory
management scheme? [3 marks]

Page 4 of 16
4) Consider the following snapshot of a system with five processes (P1, P2, P3, P4, P5) and four
resources (r1, r2, r3, r4).

Available Resources
r1 r2 r3 r4
2 1 2 0

Current Allocation Maximum Demand


Process r1 r2 r3 r4 r1 r2 r3 r4
P1 0 0 1 2 0 0 3 2
P2 2 0 0 0 2 7 5 0
P3 0 0 3 4 6 6 5 6
P4 2 3 5 4 4 3 5 6
P5 0 3 3 2 0 6 5 2

a) Compute the matrix Need. [2 marks]

b) Explain whether the system is in a safe state? If yes, provide the sequence of how processes
will finish. If not, explain why. [3 marks]

Page 5 of 16
c) If a request from P2 arrives for (0, 1, 2, 0), can that request be safely granted? Show all
working. [3 marks]

5) Consider the following information about resources and processes in the system.
 There are three processes (P1, P2, P3) and four resources (R1, R2, R3, R4). Only resource
R4 has two instances. Other resources have one instance each.
 P1 has once instance of R1 and wants one instance of R1
 P2 has one instance of R2 and wants one instance of R3
 P3 has one instance of R3 and two instances of R4. P3 wants one instance of R2

a) Draw the resource allocation graph of the above system. [5 marks]

Page 6 of 16
b) Is this system deadlocked? If yes, state which processes are deadlocked. If not, provide
execution sequence. [2 marks]

6) Consider the following possible solution to the critical section problem.

/* i is this process; j is the other process */

while (true)
{
state[i] = interested;
while (state[j] == interested);

<<< critical section >>>

state[i] = notinterested;

}
Explain whether the above algorithm guarantee bounded wait criteria. [5 marks]

Page 7 of 16
7) Consider the following algorithm.

/* i is this process; j is the other process */

while (true)
{
while (turn != i);

<<< critical section >>>

turn = j;

}
Explain whether the above algorithm can be used as a solution to the critical section
problem. [5 marks]

11)
12)
13) Processes can be in any of the five states: new, ready, running, waiting and terminated. For
the following scenarios, determine which state a process can be in. Fill in the answers in the
space provided. [3 marks]
1) Waiting to read data file. __________Waiting____________
2) Busy waiting. _______Running__________
3)
4)
5)
6)
7) I/O. _______Ready___________

Page 8 of 16
8) Answer the following questions on semaphores.
a) Assume one producer process and N consumer processes are sharing a single buffer. The
producer deposits messages into the buffer, consumers fetch them. Every message
deposited by the producer has to be fetched by all N consumers before the producer can
deposit another message into the buffer. Develop a solution for this problem using
semaphores for synchronization. [7 marks]

Page 9 of 16
b) Now, assume the buffer has b slots. The producer can deposit messages only into empty
slots and every message has to be received by all N consumers before the slot can be
reused. Furthermore, each consumer is to receive the messages in the order they were
deposited. However, different consumers can receive messages at different times. For
example, one consumer could receive up to K more messages than another if the second
consumer is slow. Extend your answer to (a) to solve this more general problem. [7 marks]

Page 10 of 16
9) Consider the following set of processes ready to be scheduled on a single CPU system.
Process Arrival Time Burst Time Priority
P1 0 10 2
P2 2 8 1
P3 3 3 3
P4 10 4 2
P5 12 1 3
P6 15 4 1
a) Draw a gantt chart and calculate waiting time for the FCFS scheduling algorithm. [2 marks]

b) Draw a gantt chart and calculate waiting time for the non-preemptive shortest job first
algorithm. [2 marks]

c) Draw a gantt chart and calculate waiting time for the preemptive PRIORITY algorithm.
[2 marks]

Page 11 of 16
10) For the following problem, assume a hypothetical machine with 4 pages of physical memory
and 7 pages of virtual memory. Given the access pattern:
ABCDEFCAAFFGABGDFF
a) How many page faults will be there if FIFO page replacement policy is used? Show all
working. [2 marks]

b) How many page faults will be there if Optimal page replacement policy is used? Show
all working. [2 marks]

c) How many page faults will be there if LRU page replacement policy is used? Show all
working. [2 marks]
d)

Page 12 of 16
11) Consider a file that is 1000 disk blocks in size. Assume that a disk block is appended to the
end of the file, which causes the file size to grow to 1001 blocks. Assume that both the file
and the file descriptor are initially on the disk and that the file buffer cache is empty.

a) Assume that the file is stored as a linked list with the pointer to the next file block stored
at the end of each block. How many disk read and write operations are required to
update the file and the file descriptor? Explain your answer. [3 marks]

b) How many disk read and write operations are required to update the file and file
description if a multi-level index scheme is used instead of a linked file organization?
Explain your answer. [3 marks]

12) Explain what protection problems may arise if a shared stack is used for parameter passing.
[2 marks]

Page 13 of 16
13) A password may become known to other users in a variety of ways. Is there a simple
method for detecting that such an event has occurred? Explain your answer. [2 marks]

14) If the virtual address is 61 bits, the page size is 1KB, the physical memory is 64KB and the
size of each page table entry is two bytes, calculate the size of the page table for both
conventional single level and inverted page table. [4 marks]

Page 14 of 16
15) For the following scenarios, explain whether it is a capability system or an access list based
approach. [6 marks]
a) Your friend gave you a key for his apartment.
b) Car parking permit lists where you are allowed to park your car.
c) A function has a list of approved guests.
d) You are in a hall of residence where you have to swipe your card to open door.

16) Explain the difference between buffering and caching. [3 marks]

Page 15 of 16
17) For the following scenarios, explain whether blocking or non blocking I/O is suitable.
[6 marks]
a) A keyboard read by an application program.
b) Network daemons listening to more than one network socket.
c) Window manager accepts mouse movements as well as keyboard inputs.
d) A copy command that copies data between I/O devices.

The End

Page 16 of 16

You might also like