Gate Qes Cpu Scheduling
Gate Qes Cpu Scheduling
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,
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)
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)
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)
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
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]
Q25- Considrer the following CPU processes with arrival times (in miliseconds) and length
of CPU bursts (in miliseconds) as given below: [2017-1]
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,
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
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,
Q30- [2022]
Q30-