You are on page 1of 3

KH5004CEM – Operating Systems and Security

Mock Exam – S2 – 2021/2022


Question 1:
Consider the following reference string:
EDHBDEDAEBEDEBG
Assume a system with only 3 frames, pure demand paging, and all frames are initially empty.
i) How many page faults would occur with a FIFO replacement scheme?
ii) How many page faults would occur with a LRU replacement scheme?
iii) How many page faults would occur with an optimal replacement scheme?

Question 2:
a) Explain the difference(s) between paging and segmentation in memory management system.
b) Compare between the Layered approach and Microkernels approach in Operating System
Structure.

Question 3:
Consider the following two processes, P0 and P1, each accessing two binary semaphores, S and
Q, set to the value 1.

P0 P1

Wait(S) Wait(S)

Wait(Q) Wait(Q)

… …

Signal(S) Signal(Q)

Signal(S) Signal(S)

What kind of unwanted situation(s) will happen? Explain your answer?


Question 4:
a) Write a multithreaded java program that outputs prime numbers. This program should work
as follows: The user will run the program and will input a number. The program will then create
a separate thread that outputs all the prime numbers less than or equal to the number entered
by the user.
b) Provide two programming examples of multithreading giving improved performance over a
single-threaded solution.
c) Provide two programming examples of multithreading that would not improve performance
over a single-threaded solution.

Question 5:
Draw the process-tree for the below program, then identify how many processes are created (Including
the initial parent process).

#include <stdio.h>

#include <unistd.h>

int main()

int i;

for (i = 0; i < 4; i++)

fork();

return 0;

Question 6:
Consider the following set of processes:

Process Arrival time Burst Time Priority


A 1 5 3
B 2 1 4
C 5 2 1(Highest)
D 6 3 2
a) Draw a diagram showing how non-preemptive SJF would schedule theprocesses. What
is the average waiting time?
b) Draw a diagram showing how FIFO would schedule the processes. What isthe average
waiting time in this case?
c) Draw a diagram showing how preemptive priority would schedule theprocesses. What
is the average waiting time in this case?
d) Compare the results for the above schedule techniques.

You might also like