1.
Introduction
2.
MCQs
3.
4.
Conclusion
Last Updated: Mar 27, 2024
Easy

# CPU Scheduling Part 1

Ankit Kumar
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

## Introduction

The topic of CPU Scheduling always remains on the tongue of the interviewers. So it is better to practice the critical questions on this topic. This blog will contain some of the necessary multiple-choice questions and their answers and a brief explanation of those answers.

Let us begin with the MCQs.

## MCQs

1. There are three CPU-intensive processes, which require 20, 30 and 40-time units and arrive at times 0, 1 and 4, respectively. What number of context switches is needed if the operating system follows the shortest remaining time first scheduling algorithm?
Ignore the context switches at time zero and the end of the execution.
A. 3
B. 4
C. 8
D. 2
Ans - Option D.
Explanation - Let us consider three processes P1, P2, and P3. At time 0, there is only one process, P1, so the CPU will execute it. At time 1, P2 arrives, but the shortest burst time left is still of P1, which will allow P1 to remain in the execution state. At time 4, P3 arrives still the shortest burst time is of P1; thus, it will continue to get executed. So far, there are no context switches, but at time 20, when the CPU will complete the execution of P1, the context will switch to P2 and subsequently to P3 when the implementation of P2 will get over. Hence there are only two context switches in this case.

2. Which of the following process scheduling algorithm may lead to starvation?
A. First In First Out
B. Time-sharing/ Round-robin
C. Shortest Job First
D. All of the above
Ans - Option C.
Explanation - The Shortest Job first algorithm does not have any feature of priority in it. Thus it may lead to starvation for a process with significant burst time.

3. Consider the following table, which contains the arrival time and burst time in milliseconds of three processes.

What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SRPT) algorithm?
A. 7.33
B. 7.00
C. 8.15
D. 7.56
Ans - Option A
Explanation -
The process P1 arrives at a time of 2 ms and completes its execution at 5 ms. The turnaround time for P1 becomes 3 ms.
The process P2 arrives at a time of 3 ms and completes its execution at 10 ms. The turnaround time for P2 becomes 7 ms.
The process P3 arrives at a time of 5 ms and completes its execution at 17 ms.
The turnaround time for P3 becomes 12 ms.
The average turnaround time is (3+7+12)/3 = 7.33 ms.

4. A scheduling algorithm is designed in such a manner that it assigns priority proportional to the waiting time of the process. At the start, every process is assigned with priority zero (the lowest priority). The scheduler re-evaluates the process priorities every T time unit and decides the next process to schedule. Which one of the following statements is correct?
Consider there is no any I/O operation of any process, and they all arrive at time zero.
A. This algorithm is equivalent to the FCFS algorithm.
B. This algorithm is equivalent to the round-robin/time-sharing algorithm.
C. This algorithm is equivalent to the shortest-job-next algorithm.
D. This algorithm is equivalent to the shortest-remaining-time-next algorithm.
Ans - Option B.
Explanation - It works as the round-robin scheduling algorithm with time quantum as T units. After a process's turn comes and it has been executed for T units, its waiting time becomes the least, and its turn comes again after every other process has got the token for T units.

5. Which of the following statements are true?
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
A. Only I
B. I and II
C. All statements are correct
D. None of the above
Ans - Option C.
Explanation - Statement 1 is correct as in the shortest remaining time first scheduling algorithm, the process with a significant burst time will face starvation. Statement 2 is also correct as any preemptive scheduling algorithm may cause starvation and the third statement is also correct as, in FCFS, the response time will be very high for the process that arrived last in the ready queue. Hence option C is correct.

6. Which of the following option is correct?
A. Hard real-time OS has less jitter than soft real-time OS
B. Hard real-time OS has more jitter than soft real-time OS
C. Hard real-time OS has equal jitter as soft real-time OS.
D. None of the above
Ans - Option A.
Explanation - The change or displacement between the signals or data being delivered is referred to as jitter. Hard real operating systems deal with more sensitive systems that require strict time deadlines, such as engine control systems and satellite launching systems, whereas soft real operating systems, such as mobile phones and online database systems, do not require strict timing constraints and allow for a slight delay. Jitter must be kept to a minimum in real-world operating systems.

7. If the quantum time of the round-robin/time-sharing scheduling algorithm is very large, then it is equivalent to which of the following?
A. FCFS
B. Shortest job first
C. Lottery scheduling
D. All of the above
Ans - Option A.
Explanation - If the time quantum is very large, then the process which arrives late will get scheduled late only, thus making it similar to the FCFS scheduling algorithm.
With this, we mark the end of this blog. I hope it gave you good learning. Let us see some of the FAQs related to CPU scheduling.
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

1. What is an Operating system?
It is system software that is helpful in managing electronic devices. It acts as an interface between the user and the computer. It has multiple utilities such as managing the hardware and software, scheduling the process depending on their priority etc.
2. Name some of the Operating systems that are widely used?
Some of the Operating systems that are widely used are Linux, Windows, macOS etc.
3. What is a process in an Operating system?
Any program which is currently under execution can be termed as a process in the Operating system. There are two types of processes.
1. Independent process
2. Cooperating process
4. What are some of the types of Operating systems?
Following are some of the types of Operating systems
1. Batch operating system
2. Time-sharing operating system
3. Real time-sharing operating system
4. Network operating system
5. What is CPU scheduling?
CPU scheduling is a way of determining which process will be executed by the CPU at a specific time. There are many algorithms that the CPU follows to determine this.

Let us now summarize our article in the next section.

## Conclusion

In this article, we extensively discussed important multiple-choice questions based on the topic of CPU scheduling. We also answered all of the questions with a brief explanation. I hope you must have gained a better understanding of CPU scheduling and its algorithms.

If you are not familiar with the topic, then you should definitely read this article to get a better understanding of CPU scheduling.

We hope that this blog has helped you enhance your knowledge regarding CPU scheduling in the Operating system. If you would like to learn more, check out our articles on Coding Ninjas Studio. Do upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass