CPU Scheduling
Question 1 
Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The average turn around time is:
13 units  
14 units  
15 units  
16 units 
Discuss it
Question 1 Explanation:
Let the processes be p0, p1 and p2. These processes will be executed in following order.
p2 p1 p2 p1 p2 p0 p1 p2 p0 p1 p2 0 4 5 6 7 8 9 10 11 12 13 14Turn around time of a process is total time between submission of the process and its completion. Turn around time of p0 = 12 (120) Turn around time of p1 = 13 (130) Turn around time of p2 = 14 (140) Average turn around time is (12+13+14)/3 = 13.
Question 2 
Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process gets blocked on I/O or when the running process finishes its compute burst. Assume that all I/O operations can be overlapped as much as possible. For what percentage of time does the CPU remain idle?
0%  
10.6%
 
30.0%
 
89.4%

Discuss it
Question 2 Explanation:
Let three processes be p0, p1 and p2. Their execution time is 10, 20 and 30 respectively. p0 spends first 2 time units in I/O, 7 units of CPU time and finally 1 unit in I/O. p1 spends first 4 units in I/O, 14 units of CPU time and finally 2 units in I/O. p2 spends first 6 units in I/O, 21 units of CPU time and finally 3 units in I/O.
idle p0 p1 p2 idle 0 2 9 23 44 47Total time spent = 47 Idle time = 2 + 3 = 5 Percentage of idle time = (5/47)*100 = 10.6 %
Question 3 
Consider three CPUintensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
1  
2  
3  
4 
Discuss it
Question 3 Explanation:
Let three process be P0, P1 and P2 with arrival times 0, 2 and 6 respectively and CPU burst times 10, 20 and 30 respectively. At time 0, P0 is the only available process so it runs. At time 2, P1 arrives, but P0 has the shortest remaining time, so it continues. At time 6, P2 arrives, but P0 has the shortest remaining time, so it continues. At time 10, P1 is scheduled as it is the shortest remaining time process. At time 30, P2 is scheduled. Only two context switches are needed. P0 to P1 and P1 to P2.
Question 4 
Which of the following process scheduling algorithm may lead to starvation
FIFO  
Round Robin  
Shortest Job Next  
None of the above 
Discuss it
Question 4 Explanation:
Shortest job next may lead to process starvation for processes which will require a long time to complete if short processes are continually added.
Question 5 
If the quantum time of round robin algorithm is very large, then it is equivalent to:
First in first out  
Shortest Job Next  
Lottery scheduling  
None of the above 
Discuss it
Question 5 Explanation:
If time quantum is very large, then scheduling happens according to FCFS.
Question 6 
A scheduling algorithm assigns priority proportional to the waiting time of a process. Every process starts with priority zero (the lowest priority). The scheduler reevaluates the process priorities every T time units and decides the next process to schedule. Which one of the following is TRUE if the processes have no I/O operations and all arrive at time zero?
This algorithm is equivalent to the firstcomefirstserve algorithm  
This algorithm is equivalent to the roundrobin algorithm.  
This algorithm is equivalent to the shortestjobfirst algorithm..  
This algorithm is equivalent to the shortestremainingtimefirst algorithm 
Discuss it
Question 6 Explanation:
The scheduling algorithm works as round robin with quantum time equals to T. After a process's turn comes and it has executed for T units, its waiting time becomes least and its turn comes again after every other process has got the token for T units.
Question 7 
Consider the 3 processes, P1, P2 and P3 shown in the table.
Process Arrival time Time Units Required P1 0 5 P2 1 7 P3 3 4The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are
FCFS: P1, P2, P3 RR2: P1, P2, P3  
FCFS: P1, P3, P2 RR2: P1, P3, P2  
FCFS: P1, P2, P3 RR2: P1, P3, P2  
FCFS: P1, P3, P2 RR2: P1, P2, P3 
Discuss it
Question 7 Explanation:
FCFS is clear. In RR, time slot is of 2 units. Processes are assigned in following order p1, p2, p1, p3, p2, p1, p3, p2, p2This question involves the concept of ready queue. At t=2, p2 starts and p1 is sent to the ready queue and at t=3 p3 arrives so then the job p3 is queued in ready queue after p1. So at t=4, again p1 is executed then p3 is executed for first time at t=6.
Question 8 
Consider the following table of arrival time and burst time for three processes P0, P1 and P2.
Process Arrival time Burst Time P0 0 ms 9 ms P1 1 ms 4 ms P2 2 ms 9 msThe preemptive shortest job first scheduling algorithm is used. Scheduling is carried out only at arrival or completion of processes. What is the average waiting time for the three processes?
5.0 ms  
4.33 ms  
6.33  
7.33 
Discuss it
Question 8 Explanation:
See Question 4 ofÂ http://www.geeksforgeeks.org/operatingsystemsset6/
Question 9 
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
I only  
I and III only  
II and III only  
I, II and III 
Discuss it
Question 9 Explanation:
I) Shortest remaining time first scheduling is a preemptive version of shortest job scheduling. In SRTF, job with the shortest CPU burst will be scheduled first. Because of this process, It may cause starvation as shorter processes may keep coming and a long CPU burst process never gets CPU.
II) Preemptive just means a process before completing its execution is stopped and other process can start execution. The stopped process can later come back and continue from where it was stopped. In preemptive scheduling, suppose process P1 is executing in CPU and after some time process P2 with high priority then P1 will arrive in ready queue then p1 is preempted and p2 will brought into CPU for execution. In this way if process which is arriving in ready queue is of higher priority then p1, then p1 is always preempted and it may possible that it suffer from starvation.
III) round robin will give better response time then FCFS ,in FCFS when process is executing ,it executed up to its complete burst time, but in round robin it will execute up to time quantum. So Round Robin Scheduling improves response time as all processes get CPU after a specified time.
So, I,II,III are true which is option (D). Option (D) is correct answer.
Reference:
https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/5_CPU_Scheduling.html
http://www.geeksforgeeks.org/operatingsystemsset7/
This solution is contributed by Nitika Bansal
Question 10 
In the following process state transition diagram for a uniprocessor system, assume that there are always some processes in the ready state: Now consider the following statements:
I. If a process makes a transition D, it would result in another process making transition A immediately. II. A process P2 in blocked state can make transition E while another process P1 is in running state. III. The OS uses preemptive scheduling. IV. The OS uses nonpreemptive scheduling.Which of the above statements are TRUE?
I and II  
I and III  
II and III  
II and IV 
Discuss it
Question 10 Explanation:
I is false. If a process makes a transition D, it would result in another process making transition B, not A.
II is true. A process can move to ready state when I/O completes irrespective of other process being in running state or not.
III is true because there is a transition from running to ready state.
IV is false as the OS uses preemptive scheduling.
There are 29 questions to complete.