Operating Systems (Theory)
Mid-Term F23 Name: ____________________
Time Allowed: 90 minutes.
Total Marks: 50 Reg#______________________
BS(CS), BS(DS)
Instructions:
• All questions are mandatory.
• Understanding the problem is part of the problem.
• If you find any mistakes in the question paper, do not panic. Make a sensible
guess and solve the questions.
Question#1: (10) Marks
Schedule the given processes using multilevel feedback scheduling policy. Draw Gantt chart
and calculate average wait time. Gantt chart must be correlated with the intermediate
calculations.
Processes Arrival Time CPU Burst
P0 0 6
P1 1 15
P2 2 3
P3 3 7
Page 1 of 5
Operating Systems (Theory)
Mid-Term F23 Name: ____________________
Time Allowed: 90 minutes.
Total Marks: 50 Reg#______________________
BS(CS), BS(DS)
Page 2 of 5
Operating Systems (Theory)
Mid-Term F23 Name: ____________________
Time Allowed: 90 minutes.
Total Marks: 50 Reg#______________________
BS(CS), BS(DS)
Question#2: Answer the following questions. Be precise when answering. Your answer to
any part must not exceed 4 lines. Otherwise, you will lose 1 mark per additional line.
(3+3+1+3 Marks)
1. Answer the following questions regarding the dual mode of operation:
a) What exactly occurs in each mode?
In kernel mode, CPU executes all instructions. However, in user mode, CPU executes only
non-privileged instructions.
b) Why was the dual mode of operation needed initially?
To protect one program from another residing in RAM.
c) Is it a hardware feature or software?
Hardware feature.
d) How is control transferred from one mode to another?
Whenever an interrupt is generated, control is transferred from user mode to kernel mode.
Return instruction in ISR returns the transfers control back to user mode.
2. Shared memory and anonymous pipes are two inter-process communication
methods. Discuss the scenarios when one is preferred over the other. (5 Marks)
Share memory is preferred to pipes when processes do not have common ancestor.
OR When volume of data is huge.
Pipes are preferred to shared memory when processes have common ancestor or
volume of data is low.
3. What will be the limitation of a system that supports dual mode of operation but
does not support system calls? (5 Marks)
System call is a mechanism to run the privileged code in kernel mode that can’t be
executed in user mode by switching to mode to kernel from user. Having no
provision to system calls, user programs can’t request OS to perform privileged
tasks.
Question#3
Page 3 of 5
Operating Systems (Theory)
Mid-Term F23 Name: ____________________
Time Allowed: 90 minutes.
Total Marks: 50 Reg#______________________
BS(CS), BS(DS)
a) Draw process tree for the following code. Also, write the output of the code. (5+5
marks)
Page 4 of 5
Operating Systems (Theory)
Mid-Term F23 Name: ____________________
Time Allowed: 90 minutes.
Total Marks: 50 Reg#______________________
BS(CS), BS(DS)
b) Write a C program to implement the following shell command. (10 Marks)
$ ps -ef --forest | grep “10”
Page 5 of 5