0% found this document useful (0 votes)
133 views

Gate Qes Cpu Scheduling

The document contains 18 multiple choice questions related to CPU scheduling algorithms. The questions cover algorithms like Round Robin (RR), Shortest Job First (SJF), Priority Scheduling, and Shortest Remaining Time First (SRTF). Key details summarized: - RR scheduling aims to limit waiting times for shorter jobs but favors shorter jobs. - SJF and SRTF algorithms minimize average waiting/turnaround times by prioritizing shorter remaining/burst times. - Priority scheduling that assigns priority proportional to waiting time is equivalent to RR.

Uploaded by

Vyom Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Gate Qes Cpu Scheduling

The document contains 18 multiple choice questions related to CPU scheduling algorithms. The questions cover algorithms like Round Robin (RR), Shortest Job First (SJF), Priority Scheduling, and Shortest Remaining Time First (SRTF). Key details summarized: - RR scheduling aims to limit waiting times for shorter jobs but favors shorter jobs. - SJF and SRTF algorithms minimize average waiting/turnaround times by prioritizing shorter remaining/burst times. - Priority scheduling that assigns priority proportional to waiting time is equivalent to RR.

Uploaded by

Vyom Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Q1 The highest-response ratio next scheduling policy favours……….

jobs, but it also limits


the waiting time of…….jobs. [1990]
Solution: (Shorter, Longer)
By applying RR-scheduling with time ts = 1,
Gantt Chart,

Turn-around time = 9
----------------------------------------------------------------------------------------------------------------
Q2 - Assume that the following jobs are to be executed on a single-processor system
Job ID CPU-Burst Time
p 4
q 1
r 8
s 1
t 2
The jobs are assumed to have arrived at time 0 and in the order p, q, r, s, t. Calculate the
departure time (completion time) for job p if scheduling is round robin with time slice 1.
[1993]
(a) 4 (b) 10 (c) 11 (d) 12
Solution: (c)
Apply RR scheduling with ts = 1.
Gantt Chart,

Turnaround time = 11.


Hance the correct option is (c)
----------------------------------------------------------------------------------------------------------------
Q3- Which scheduling policy is most suitable for a time-shared operating system? [1995]
(a) Shortest job first (b) Round robin
(c) First come first serve (d) Elevator
Solution (b)
Round Robin pre-emptive scheduler and designed especially for time sharing systems. In RR,
a process is allotted a time slot (called time slice) and if the process does not finish, process
will 'get back in line' and another process will receive the time slot.
Hance the correct option is (b)
----------------------------------------------------------------------------------------------------------------
Q4- The sequence …………… is an optimal non-preemptive scheduling sequence for the
following jobs which leaves the CPU idle for …………unit(s) of time. [1995]
Job Arrival Time Burst Time
1 0.0 9
2 0.6 5
3 1.0 1
(a) {3,2,1},1 (b) {2,1,3},0 (c) {3,2,1},0 (d) {1,2,3},5
Solution: (a)
SJF is optional non-pre-emptive CPU scheduling algorithm. In order to produce the optimal
Solution here, it considers the SJF. The optimal sequence is {j3, j2, j1}.
Since burst time(j3) < burst time(j2) < burst time(j1), but to start j3, CPU should wait for 1.0
units of time as its interval time is 1.0.
Hance the correct option is (a)
----------------------------------------------------------------------------------------------------------------
Q5- Four jobs to be executed on a single-processor system arrive at time 0 in the order A, B,
C, D. Their burst CPU time requirements are 4, 1, 8, 1 time units, respectively. The
completion time of A under round robin scheduling with time slice of one time unit is [1996]
(a) 10 (b) 4 (c) 8 (d) 9
Solution: (d)
----------------------------------------------------------------------------------------------------------------
Q6- Four jobs are waiting to be run. Their expected runtimes are 6, 3, 5 and x. In what order
should they be run to minimize the average response time? [1998]
Solution: ()
Run in the order
x, 3, 5, 6, if x < 3
3, x, 5, 6, if x > 3 & x < 5
3, 5, x, 6, if x > 5 & x < 6
3, 5, 6, x, if x > 6
By applying SJF; as it generates the least any
waiting time.
There are only two main choices FCFS and SJF
as no priority and quantum size has been given.
Moreover, x may take values 1, 2, 3, 4, 5 and
more than that. It is assumed that the job spounds
immediately after getting the CPU. Then the
response time will be same as waiting time.
SJF is considered as it produces minimum response
time.
CASE 1 : x = 1
Average waiting time = (0 + 1 + 4 + 9)/4 = 14/4 =
3.5

CASE 2 : x = 2
This job will again be the first job to be executed.
Average waiting time = (0 + 2 + 5 + 10)/4 = 17/4 = 4.25
CASE 3 : x = 3
This job will again be the first job to be executed.
Average waiting time = (0 + 3 + 6 + 11)/4 = 20/4 =
5
CASE 2 : x = 4
Average waiting time = (0 + 3 + 7 + 12)/4 = 22/4 = 5.5
And so on.
Thus , the order of execution depends on the value
of x and average response time is minimum x = 1.
----------------------------------------------------------------------------------------------------------------
Q7- Consider n processes sharing the CPU in a roundrobin
fashion. Assuming that each process which
takes s seconds, what must be the quantum size
q such that the overhead resulting from process
switching is minimized but, at the same time, each
process is guaranteed to its turn at CPU at least
every second? [1998]
Solution: (b)
Each process runs for q period and if there are n
process p1, p2, p3…pn, p1, p2…., then p1 turn
comes again when it has a complete time quanta
for remaining process p2 to pn, i.e., it would take
at most(n-1) q times. So, each process in round
robin gets its turn after < = (n - 1) q times when
we don’t consider overhead but if we consider
overhead(s) but if we consider overhead then it would
be ns + (n - 1) q. So, ns + (n - 1) q < = t, overhead will be reduced when time quantum is
maximum
allowable, i.e, q = t - ns / (n - 1).
Hance the correct option is (b)

Q8- Consider a set of n tasks with known runtimes r1, r2


….., rn to be run on a uniprocessor machine. Which
of the following processor scheduling algorithm
will result in the maximum throughput? [2001]
(a) Round robin
(b) Shortest-job-first
(c) First-in first-out
(d) First-come-first serve
Solution: (b)
Total number of jobs executed in per unit time is
maximum in SJF.
Hance the correct option is (b)
Q9- Which of the following scheduling algorithms is
non-pre-emptive? [2002]
(a) Round robin
(b) First-in-first-out
(c) Multilevel queue scheduling
(d) Multilevel queue scheduling with feedback
Solution: (b)
In FIFO, pre-emption takes place only after the
completion of a process.
Hance the correct option is (b)
Q10- Consider the following set of processes, with the
arrival times and the CPU burst times given in
milliseconds.
Process Arrival Time Burst Time
P1 0 5
P2 1 3
P3 2 3
P4 4 1
What is the average turnaround time for these processes
with the pre-emptive Shortest Remaining
Processing Time first (SROT) algorithm? [2004]
(a) 5.50 (b) 5.75
(c) 6.00 (d) 6.25
Solution: (a)

Gantt Chart
Turn around time for P1 = 12 - 0 = 12
Turn around time for P2 = 4 - 1 = 3
Turn around time for P3 = 8 - 2 = 6
Turn around time for P4 = 5 - 4 = 1
Average TAT = 12 + 3 + 6 + 1/4 = 5.50
Hance the correct option is (a)

Q11Consider 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 turnaround time is [2006]
(a) 13 units (b) 14 units
(c) 15 units (d) 16 units
Solution: (a)

Avg TAT = 12 + 13 + 14/3 = 13


Hance the correct option is (a)

Q12- Consider three CPU-sensitive 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
the shortest remaining time first scheduling
algorithm? Do not count the context switches at
time zero and at the end. [2006]
(a) 1 (b) 2
(c) 3 (d) 4
Solution:(b)

There are 4 context switching out of which 2 are


removed.
Hance the correct option is (b)

Q14- An operating system uses the Shortest Remaining


Time first (SRT) process scheduling algorithm.
Consider the arrival times and execution times for
the following processes:
Process Execution time Arrival time
P1 20 0
P2 25 15
P3 10 30
P4 15 45
What is the total waiting time for process P2?
[2007]
(a) 5 (b) 15
(c) 40 (d) 55
Solution: (b)
Hance the correct option is (b)

Q15- 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. [2010]
(a) I only (b) I and II only
(c) II and III only (d) I, II and III only
Solution: (d)
All statements are true.
Hance the correct option is (d)
Q16- 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 ms
The pre-emptive 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?
[2011]
(a) 5.0 ms (b) 4.33 ms
(c) 6.33 ms (d) 7.33 ms
Solution: (a)
By Gantt chart

WT for P0 = [5 - 1] - 0 = 4
WT for P1 = [1 - 1] = 0
WT for P2 = [13 - 2] = 11
Average WT for = 4 + 0 + 11/3 = 15/3 = 5
Hance the correct option is (a)

Q17- Consider the 3 processes, P1, P2 and P3 shown in


the table
Process Arrival time Time unit required
P1 0 5
P2 1 7
P3 3 4
The completion order of the 3 processes under the
policies FCFS and RRS (round robin scheduling
with CPU quantum of 2 time units) are
[2012]
(a) FCFS: P1, P2, P3 RR2: P1, P2, P3
(b) FCFS: P1, P3, P2 RR2: P1, P3, P2
(c) FCFS: P1, P2, P3 RR2: P1, P3, P2
(d) FCFS: P1, P3, P2 RR2: P1, P2, P3
Solution: (c)
Hance the correct option is (c)

Q18- A scheduling algorithm assigns priority proportional


to the waiting time of a process. Every process
starts with priority zero (the lowest priority).
The scheduler re-evaluates 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? [2013]
(a) This algorithm is equivalent to the first come
first serve algorithm.
(b) This algorithm is equivalent to round robin
algorithm.
(c) This algorithm is equivalent to the SJF
algorithm.
(d) This algorithm is equivalent to the
shortest-remaining-job-first algorithm.
Solution: (b)
Once every process got scheduled one time each
(for T times unit), all process now have the same
waiting time = (n - 1) T where n = # process.
Till now, the scheduling was round robin with preemption
at periods of T. The same analysis can be
extended for further scheduling as all the process
have the same priority = (n - 1)T.
Hance the correct option is (b)

Q19- Consider the following set of processes that need


to be scheduled on a single CPU. All the times are
given in millisecond. [2014]
Process Arrival time Burst time
A 0 6
B 3 2
C 5 4
D 7 6
E 10 3
Using the shortest remaining time first scheduling
algorithm, the average process turnaround time (in
MS) is ___________
Solution: ( 7.2)
Processes are scheduled in the order <A; B; A; C;
E; D> at times 0, 3, 5, 8, 12, 15, 21; giving an average
turnaround time of 7.2.

Q20- An operating system uses the shortest remaining


time first scheduling of processes. Consider the
following set of processes with their arrival times
and CPU burst time (in millisecond): [2014]
Process Arrival time Burst time
P1 0 12
P2 2 4
P3 3 6
P4 8 5
Solution: (5.5)
The process gets scheduled in the order <p1; p2;
p3; p4; p1> generating a schedule length of 27,
and hence average waiting time of 22/4 = 5.5

Q21- For the processes listed in the following table, which of the following scheduling
schemes will give the lowest average turnaround time? [2015-2]
Arriva Processin
Proces
l g
s
Time Time
A 0 3
B 1 6
C 4 4
D 6 2

(A)  First Come First Serve (B)  Non – preemptive Shortest Job First

(C)  Shortest Remaining Time  (D)  Round Robin with Quantum value two

Solution:  (C) Shortest Remaining Time

Q22- Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is


composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals
of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period,
and the available tasks are scheduled in order of priority, with the highest priority task
scheduled first. Each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4
milliseconds, respectively. Given that all tasks initially arrive at the beginning of the
1st millisecond and task preemptions are allowed, the first instance of T3 completes its
execution at the end of ______ milliseconds. [2015-2]

Answer : 12
Q23- Consider the following processes, with the arrival time and the length of the CPU burst
given in milliseconds. The scheduling algorithm used is preemptive shortest remaining-time
first. [2016-2]

Proces Arrival Burst


s Time Time
P1P1 0 10
P2P2 3 6
P3P3 7 1
P4P4 8 3
 
The average turn around time of these processes is milliseconds ________.
Answer : 8.2 : 8.3
Q24- Consider the set of processes with arrival time (in milliseconds), CPU burst time (in
milliseconds) , and priority (0 is the highest priority) shown below. None of the processes
have I/O burst time. [2017-2]

Process Arrival time Burst Time Priority 


P1 0 11 2
P2 5 28 0
P3 12 2 3
P4 2 10 1
P5 9 16 4
The average waiting time (in milliseconds) of all the processes using preemptive priority
scheduling algorithm is _____________.

Answer : 29.0 to 29.0

Q25- Considrer the following CPU processes with arrival times (in miliseconds) and length
of CPU bursts (in miliseconds) as given below: [2017-1]

Process Arrival time Burst time


P1 0 7
P2 3 3
P3 5 5
P4 6 2
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the
processes, then the average waiting time across all processes is _________ milliseconds.

Answer : 3.0

Q26- Consider the following four processes with arrival times (in milliseconds) and their
length of CPU bursts (in milliseconds) as shown below: [2019-2]

Process P1 P2 P3 P4
Arrival time 0 1 3 4
CPU burst time 3 1 3 Z

These processes are run on a single processor using preemptive Shortest Remaining Time
First scheduling algorithm. If the average waiting time of the processes is 1 millisecond, then
the value of Z is________.
Answer : 2 to 2
Q27- Consider the following set of processes, assumed to have arrived at time 0. Consider
the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR,
assume that the processes are scheduled in the order P1, P2, P3, P4.

If the time quantum for RR is 4 ms, then the absolute value of the difference between the
average turnaround times (in ms) of SJF and RR (round off to 2 decimal places) is
_________ .
Solution: According to Shortest Job First (or SJF) CPU Scheduling, gantt chart is,
Therefore, Average Turn Around Time (TAT) is,

= {(21 – 0) + (13 – 0) + (2 – 0) + (6 – 0)} / 4


= 10.5
Now, according to Round Robin (RR) CPU Scheduling with time quantum 4, gantt chart is,

Therefore, Average Turn Around Time (TAT) is,


= {(18 – 0) + (21 – 0) + (10 – 0) + (14 – 0)} / 4
= 15.75
Hence,
= ⏐SJF (TAT) – RR(TAT)⏐
= ⏐10.5 – 15.75⏐
= 5.25

Q28- Which of the following statement(s) is/are correct in the context of CPU scheduling?
[2021-2]
(A) Turnaround time includes waiting time
(B) The goal is to only maximize CPU utilization and minimize throughput
(C) Round-robin policy can be used even when the CPU time required by each of the
processes is not known apriori
(D) Implementing preemptive scheduling needs hardware support

Answer: (A) (C) (D)

Explanation:
Turnout time is a combination of waiting time and burst time.
The goal of CPU scheduling to maximize CPU utilization & throughput and to minimize
turnaround time, waiting time, and response time.
In Round-Robin there is no such requirement of knowing burst time in prior. It is sufficient
condition for SJF(Shortest job First)
Implementing preemptive scheduling also require hardware support because of it we can
swap the process between states.
Option (A), (C), (D) are correct.

Q29- Three processes arrive at time zero with CPU bursts of 16, 20 and 10 milliseconds. If
the scheduler has prior knowledge about the length of the CPU bursts, the minimum
achievable average waiting time for these three processes in a non-preemptive scheduler
(rounded to nearest integer) is _____________ milliseconds. [2021-1]
(A) 12
(B) 36
(C) 46
(D) 10
Answer: (A)

Explanation: Use SRTF, for the minimum achievable average waiting time :
Gantt chart is,

Since, TAT = CT – AT and WT = TAT – BT, so WT = CT – AT – BT = CT – (AT+BT)


Therefore,
Avg, WT
= {(26-0-16) + (46-0-20) + (10-0-10)} / 3
= {10 + 26 + 0} / 3
= 36 / 3
= 12

Q30- [2022]

Q30-

You might also like