Introduction
In this article, we will discuss some of the important questions related to CPU scheduling algorithms. We will see some of the theoretical and numerical questions related to scheduling as well and will hope that you can extract benefits from this and do well in your upcoming interviews. The Multiple-choice questions will be followed by their answer and a brief explanation about them.
Let us begin with the MCQs.
MCQs
1.Let us consider three processes with process id 1, 2, and 3, respectively, and their burst time is 1, 3 and 7-time units, respectively. Every process arrives at time zero. Let us suppose the CPU follows the longest remaining time first (LRTF) scheduling algorithm, and In LRTF, ties will be broken by giving priority to the process with the lowest process id. What will be the average turnaround time for these three processes?
A. 13 units
B. 15 units
C. 10 units
D. 12 units
Ans Option C
Explanation - If the CPU follows an LRTF algorithm, then the processes will be executed in the following order.
With the above Gantt chart, we can derive the following things.
Turn around time for P1 is (9-0) = 9
Turn around time for P2 is (10-0) = 10
Turn around time for P3 is (11-0) = 11
Hence the average turn around time is (9+10+11)/3 = 30/3 = 10 units.
2. Let us Consider the three processes, P0, P1 and P2, given in the following table.
What will be the order of completion of the CPU following the First Come, First Serve scheduling algorithm?
A. P0 - P1 - P2
B. P1 - P2 - P0
C. P2 - P1 - P0
D. P0 - P2 - P1
Ans - Option D
Explanation - The first-come, the first-serve scheduling algorithm is a non-preemptive kind of algorithm that executes the process which arrived earliest in the CPU unless they need to perform I/O operations. In the given scenario, there are no I/O operations required by any one of the processes, so the order of execution of the processes will be P0 - P2 - P1.
Hence option d will be the correct answer.
3. Match the following groups, where column1 contains some of the CPU scheduling algorithms, and column2 contains their applications.
Choose the correct option
A. 1-A, 2-B, 3-C
B. 1-B, 2-C, 3-A
C. 1-C, 2-B, 3-A
D. 1-B, 2-A, 3-C
Ans Option C
Explanation - Gang scheduling is a kind of scheduling algorithm that schedules related threads to run simultaneously on different processors. The Fair-share scheduling algorithm distributes the CPU usage equally to all the processes; hence it is a guaranteed scheduling algorithm, and the Rate monotonic scheduling algorithm is used in real-time operating systems due to its scheduling strategy. Hence Option C is the correct match for this problem.
4. What is the maximum number of processes that can be in a Ready state for a computer system with n CPUs?
A. n
B. n^2
C. 2n
D. Not dependent on n
Ans Option D
Explanation - The maximum number of processes that can be in the ready state is not at all dependent on n, as there can be an infinite number of processes present in the ready state.
5. Which of the following statement is/are incorrect about SJF (Shortest Job first scheduling algorithm)?
Statement 1 - The average waiting time is minimum for it.
Statement 2 - It causes starvation.
A. Only statement 1
B. Only statement 2
C. Both of the Statements
D. None of the statements
Ans Option D
Explanation - The Shortest Job First algorithm can cause starvation for the process with a significant amount of burst time as there is no concept of priority in it, and the average waiting time is though optimal but not minimum in the SJF algorithm.
With this, we end this blog. Let us now see some of the Frequently Asked Questions.