Professional Documents
Culture Documents
1.practice Questions and Solutions Set-1
1.practice Questions and Solutions Set-1
OS PRACTICE SET - 1
(Processes - States, PCB, Schedulers, Threads and System calls, CPU scheduling - FCFS,
SJFS, priority scheduling, Round robin, multi level queue scheduling, multilevel feedback queue
scheduling)
[Updated : 11/Sep/2020]
1) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using first come first serve scheduling algorithm.
P1 0 5
P2 2 3
P3 6 2
P4 7 3
Solution : Average Turnaround Time = 5.25, Average Waiting Time = 2.00, Average
Response Time = 2.00, Throughput = 0.31 process/unit time.
2) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using first come first serve scheduling algorithm.
P1 1 5
P2 2 3
P3 3 8
P4 7 3
Solution : Average Turnaround Time = 9.75, Average Waiting Time = 5.00, Average
Response Time = 5.00, Throughput = 0.2 process/unit time
3) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using first come first serve scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
P4 9 3
Solution : Average Turnaround Time = 7.50, Average Waiting Time = 2.75, Average
Response Time = 2.75, Throughput = 0.19 process/unit time
4) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using first come first serve scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 0.67, Average
Response Time = 0.67, Throughput = 0.17 process/unit time
5) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using first come first serve scheduling algorithm.
P1 0 5
P2 7 8
P3 8 8
Solution : Average Turnaround Time = 9.33, Average Waiting Time = 2.33, Average
Response Time = 2.33, Throughput = 0.13 process/unit time
6) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time and average waiting time using
Shortest Job first scheduling algorithm.
P1 0 5
P2 2 3
P3 6 2
P4 7 3
Solution : Average Turnaround Time = 5.25, Average Waiting Time = 2.00, Average
Response Time = 2.00, Throughput = 0.31 process/unit time
7) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time and average waiting time using using
Shortest Job first scheduling algorithm.
P1 1 5
P2 2 3
P3 3 8
P4 7 3
Solution : Average Turnaround Time = 8.5, Average Waiting Time = 3.75, Average
Response Time = 3.75, Throughput = 0.2 process/unit time
8) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time and average waiting time using using
Shortest Job first scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
P4 9 3
Solution : Average Turnaround Time = 6.25, Average Waiting Time = 1.50, Average
Response Time = 1.50, Throughput = 0.19 process/unit time
9) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time and average waiting time using using
Shortest Job first scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 0.67, Average
Response Time = 0.67, Throughput = 0.17 process/unit time
10) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using Non preemptive Priority scheduling algorithm.
(Higher number implies higher priority)
P1 0 5 1
P2 2 3 2
P3 6 2 3
P4 7 3 4
Solution : Average Turnaround Time = 5.50, Average Waiting Time = 2.25, Average
Response Time = 2.25, Throughput = 0.31 process/unit time
11) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using Non preemptive Priority scheduling algorithm.
(Higher number implies higher priority)
P1 1 5 1
P2 2 3 3
P3 3 8 5
P4 7 3 2
Solution : Average Turnaround Time = 11.00, Average Waiting Time = 6.25, Average
Response Time = 6.25, Throughput = 0.20 process/unit time
12) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using Non preemptive Priority scheduling algorithm.
(Higher number implies higher priority)
P1 0 5 2
P2 7 3 1
P3 8 8 4
P4 9 3 0
Solution : Average Turnaround Time = 7.50, Average Waiting Time = 2.75, Average
Response Time = 2.75, Throughput = 0.19 process/unit time
13) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using Non preemptive Priority scheduling algorithm.
(Higher number implies higher priority)
P1 0 5 1
P2 7 3 2
P3 8 8 0
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 0.67, Average
Response Time = 0.67, Throughput = 0.17 process/unit time
14) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using Non preemptive Priority scheduling algorithm.
(Higher number implies higher priority)
P1 0 5 3
P2 7 6 1
P3 7 8 0
Solution : Average Turnaround Time = 8.33, Average Waiting Time = 2.00, Average
Response Time = 2.00, Throughput = 0.14 process/unit time
15) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using preemptive Priority scheduling algorithm. (Higher
number implies higher priority)
P1 0 5 1
P2 2 3 2
P3 6 2 3
P4 7 3 4
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 2.75, Average
Response Time = 0.00, Throughput = 0.31 process/unit time
16) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using preemptive Priority scheduling algorithm.(Higher
number implies higher priority)
P1 1 5 1
P2 2 3 3
P3 3 8 5
P4 7 3 2
Solution : Average Turnaround Time = 11.75, Average Waiting Time = 7.00, Average
Response Time = 1.50, Throughput = 0.21 process/unit time
17) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using preemptive Priority scheduling algorithm.(Higher
number implies higher priority)
P1 0 5 2
P2 7 3 1
P3 8 8 4
P4 9 3 0
Solution : Average Turnaround Time = 9.00, Average Waiting Time = 4.25, Average
Response Time = 2.25, Throughput = 0.19 process/unit time
18) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using preemptive Priority scheduling algorithm.(Higher
number implies higher priority)
P1 0 5 1
P2 7 3 2
P3 8 8 0
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 0.67, Average
Response Time = 0.67, Throughput = 0.17 process/unit time
19) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using preemptive Priority scheduling algorithm. (Higher
number implies higher priority)
P1 0 5 3
P2 7 6 1
P3 7 8 0
Solution : Average Turnaround Time = 8.33, Average Waiting Time = 2.00, Average
Response Time = 2.00, Throughput = 0.14 process/unit time
20) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using SRTF scheduling algorithm.
P1 0 5
P2 2 3
P3 6 2
P4 7 3
Solution : Average Turnaround Time = 5.25 Average Waiting Time = 2.00 Average
Response Time = 2.00 Throughput = 0.31 process/unit time
21) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using SRTF scheduling algorithm.
P1 1 5
P2 2 3
P3 3 8
P4 7 3
Solution : Average Turnaround Time = 8.25, Average Waiting Time = 3.50, Average
Response Time = 2.75, Throughput = 0.21 process/unit time
22) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using SRTF scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
P4 9 3
Solution : Average Turnaround Time = 6.25, Average Waiting Time = 1.50, Average
Response Time = 1.50, Throughput = 0.19 process/unit time
23) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using SRTF scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 0.67, Average
Response Time = 0.67, Throughput = 0.17 process/unit time
24) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using SRTF scheduling algorithm.
P1 0 5
P2 7 8
P3 8 8
Solution : Average Turnaround Time = 9.33, Average Waiting Time = 2.33, Average
Response Time = 2.33, Throughput = 0.13 process/unit time
25) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using RR scheduling algorithm, time quantum=2.
P1 0 5
P2 2 3
P3 6 2
P4 7 3
Solution : Average Turnaround Time = 6.00, Average Waiting Time = 2.75, Average
Response Time = 1.00, Throughput = 0.31 process/unit time
26) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using RR scheduling algorithm, time quantum=3.
P1 1 5
P2 2 3
P3 3 8
P4 7 3
Solution : Average Turnaround Time = 10.25, Average Waiting Time = 5.50, Average
Response Time = 2.75, Throughput = 0.29 process/unit time
27) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using RR scheduling algorithm, time quantum=2.
P1 0 5
P2 7 3
P3 8 8
P4 9 3
Solution : Average Turnaround Time = 8.25, Average Waiting Time = 3.50, Average
Response Time = 0.75, Throughput = 0.24 process/unit time
28) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using RR scheduling algorithm, time quantum=2.
P1 0 5
P2 7 3
P3 8 8
Solution : Average Turnaround Time = 6.67, Average Waiting Time = 1.33, Average
Response Time = 0.33, Throughput = 0.17 process/unit time
29) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, average turn around, average
response time and throughput, using RR scheduling algorithm, time quantum=1.
P1 0 5
P2 7 8
P3 8 8
Solution : Average Turnaround Time = 11.67, Average Waiting Time = 4.67, Average
Response Time = 0.00, Throughput = 0.13 process/unit time
30) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, and average turn around, using HRRN
scheduling algorithm.
P1 0 5
P2 2 3
P3 6 2
P4 7 3
Solution : Average waiting time: 2.000000, Average Turn Around time: 5.250000
31) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, and average turn around, using HRRN
scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
P4 9 3
32) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, and average turn around, using HRRN
scheduling algorithm.
P1 0 5
P2 7 3
P3 8 8
33) Consider the process information for set of processes, assuming the context switch
delay to be 0, calculate the average waiting time, and average turn around, using HRRN
scheduling algorithm.
P1 0 5
P2 7 8
P3 8 8
42) The process in which of the following states will be in secondary memory?
45) Which technique was introduced because a single job could not keep both the CPU and I/O
devices busy?
46) Consider a system with ‘M’ CPU processors and ‘N’ processes then how many processes can
be present in ready, running and blocked state at minimum
47) Consider a system with ‘M’ CPU processors and ‘N’ processes then how many processes can
be present in ready, running and blocked state at maximum
(a) N, M, N (b) N, M, M
(c) M, N, M (d) N, N+M, M
(a) CTi – Ati where CTi is Completion time and ATi is Arrival time
(b) BTi + WTi where BTi is Burst time and WTi is Waiting time
(c) None of the above
(d) Both (a) and (b)
int main()
{
fork();
printf("Hello world!");
return 0;
}
52) The number of child processes are created using the following code :
int main()
{
fork();
fork();
fork();
return 0;
}
Solution : 7
int main()
{
int x = 1;
if (fork() == 0)
printf("Child has x = %d\n", ++x);
else
printf("Parent has x = %d\n", --x);
}
Solution : 0,2
A. program counter
B. stack
Solution : C
Solution :
Factors User Level Threads Kernel Level Threads
Context switch Context switch time is less. Context switch time is more.
If one user level thread perform If one kernel thread perform blocking
Impact of IO blocking operation then entire operation then another thread can
calls process will be blocked. continue execution.
58) Consider the processes and Burst times as shown below which follows SJF scheduling
algorithm:
Processes AT BT
P1 0 4
P2 0 2
P3 1 5
P4 1 3
59) Which of the following algorithms gives minimum average Response time?
60) When a process is using CPU and if an interrupt occurs, the process will be moved to:
62) In real time Operating System, which of the following is the most suitable scheduling
scheme?
65) In Round Robin Scheduling Algorithm if Time Quantum is very small it results in:
(a) Maximum Average Waiting Time (b) Minimum Average Waiting Time
(c) More number of Context Switches (d) None of the above
66) In Round Robin if the Time Quantum is very large then it will behave as:
67) Which of the following information is not part of Process Control Block?
68) Given n-processes (P1, P2,…..Pn) and bti is the actual burst time of P i and bt1, bt2,…., btn are
the burst times of a processes P 1, P2,…Pn. What is the predicted burst time for process P i using
Simple Average?
n+1
1
(a) Tn+1 = n ∑ bti
i=1
1 n
(b) Tn+1 = + n ∑ bti
n
i=1
n
1
(c) Tn+1 = n ∑ bti
i=1
1
(d) Tn+1 = n
∑ bti
2n
i=1
Solution: Option(c)
69) Consider the actual Burst time of the processes are 2, 5, 3, 9, 6 respectively. What is the
predicted Burst time of the next process using simple average?
(a) 25 (b) 5
(c) 10 (d) 15
70) What is the predicted burst time for process Pi where tn is the actual burst of previous process
and Tn is the predicted burst time of the previous process.
(a) Tn+1 = ∝T n + (1 − ∝) 0≤ ∝ ≤1
tn−1
0≤ ∝ ≤1
(b) Tn+1 = ∝tn + (1 − ∝) T n
71) If 𝛼=0.4 and T1=10. Consider the actual burst times of t1, t2, t3 are 5, 7, 2 respectively. What
is the predicted burst time of t4 using Exponential Average method?
72) Consider the processes P1, P2, P3, P4 whose arrival times are 1, 5, 9, 10 and burst times are 4,
3, 5, 2 respectively. If the processes follow FCFS, what is the CPU idle time?
73) When two or more processes trying to execute a set of instructions and if the output depends
on the order of execution of the process, this is termed as: