FCFS and SJF Scheduling in OS – GATE Notes

Ques 1.FCFS PYQ – GATE 2026 (Set-1) – 2 MarksQuestion:

Consider a system which has to execute two types of processes. The first type, Actuators (A), requires a CPU burst of 6 seconds. The second type, Controllers (C), requires a CPU burst of 8 seconds. A new process of type A arrives at time t = 10, 20, 30, 40, and 50 (in seconds). Similarly, a new process of type C arrives at time t = 11, 22, 33, 44, and 55 (in seconds). The CPU scheduling policy is First Come First Serve (FCFS). The first process of type A starts running at t = 10 seconds. The average waiting time (in seconds) for the 10 processes is __ (rounded off to one decimal place)

Answer: 9.5
Gantt Chart: A1(10-16) -> C1(16-24) -> A2(24-30) -> C2(30-38) -> A3(38-44) -> C3(44-52) -> A4(52-58) -> C4(58-66) -> A5(66-72) -> C5(72-80)
Waiting = Start – Arrival. Total = 95 / 10 = 9.5

Ques2.FCFS PYQ – GATE 2026 (Set-2) – 1 MarkQuestion:
Which one of the following CPU scheduling algorithms cannot be preemptive?
(a) Shortest Remaining Time First (SRTF) Scheduling
(b) First Come First Serve (FCFS) Scheduling
(c) Round Robin Scheduling
(d) Priority SchedulingAnswer:

Ans-(b) FCFS
FCFS is always non-preemptive. SRTF and Priority can be both, RR is preemptive by definition.

Q3. [GATE 2025 Set-2 : 1M] – SRTF (Preemptive SJF)
Processes P1,P2,P3,P4 arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times. Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?
(a) 22 (b) 15 (c) 37 (d) 19

Solution:
Gantt Chart:
| P1 0-2 | P3 2-8 | P1 8-16 | P4 16-25 | P2 25-38 |

t=0-2: P1 runs, P2,P3 arrive. Shortest is P3(6)

t=2-8: P3 runs and finishes at 8.

t=8: P4 arrives. Ready: P1(8), P2(13), P4(9) -> P1 runs 8-16, finishes.

t=16: Ready: P4(9), P2(13) -> P4 runs 16-25.

t=25: P2 runs 25-38.

Turnaround Time (CT-AT):
P1=16−0=16
P2=38−1=37
P3=8−2=6
P4=25−8=17
Total = 76
Avg TAT = 76/4 = 19 ms

Answer: (d) 19

Ques4 [GATE 2024 Set-2 : 2M] [SRTF and NP-SJF Based]
Consider a single processor system. There are four processes A,B,C,D with arrival times and CPU burst times as follows:

ProcessArrival TimeBurst Time
A010
B26
C43
D67

What is the average waiting time for (a) SRTF and (b) Non-preemptive SJF ?Options:
(a) SRTF=6.5, NP-SJF=7.5
(b) SRTF=6.5, NP-SJF=8
(c) SRTF=6, NP-SJF=7.5
(d) SRTF=6, NP-SJF=8Solution:1. SRTF (Preemptive SJF)
Gantt Chart:
| A 0-2 | B 2-4 | C 4-7 | B 7-11 | D 11-18 | A 18-26 |

A: CT=26, TAT=26-0=26, WT=26-10= 16

B: CT=11, TAT=11-2=9, WT=9-6= 3

C: CT=7, TAT=7-4=3, WT=3-3= 0

D: CT=18, TAT=18-6=12, WT=12-7= 5

Total WT = 16+3+0+5 = 24
Avg WT (SRTF) = 24/4 = 6

2. NP-SJF (Non-Preemptive)
Gantt Chart:
| A 0-10 | C 10-13 | B 13-19 | D 19-26 |

A: CT=10, WT=0

C: CT=13, WT=10-4=6

B: CT=19, WT=13-2=11

D: CT=26, WT=19-6=13

Total WT = 0+6+11+13 = 30
Avg WT (NP-SJF) = 30/4 = 7.5

Answer: (c) SRTF = 6, NP-SJF = 7.5

Ques-5[GATE 2021Set-1 : 1M] [SJF Based]

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 is __ milliseconds.

Solution (SJF = Minimum Avg WT):Minimum Avg Waiting Time hamesha SJF (Shortest Job First) deta hai.

Order: Burst ke hisaab se sort karo -> 10, 16, 20

ProcessBTCTWT=CT-BT
P310100
P1162610
P2204626

Total WT = 0 + 10 + 26 = 36

Avg WT = 36 / 3 = 12

Gantt: | P3(10) 0-10 | P1(16) 10-26 | P2(20) 26-46 |

Answer: 12 ms

Question6:[GATE 2019 : 2M] [SRTF Based]
Consider 4 processes with AT and BT:

ProcessArrivalBurst
P103
P211
P333
P44Z

Run on single processor using Preemptive SRTF. If average waiting time = 1 ms, then value of Z is ?

Solution:SRTF = Jo bacha hua time sabse kam hai usko pehle.

Gantt banao:

0-1: P1 chala (Remaining P1=2)

1-2: P2 aaya (BT=1) < P1(2) -> P2 chala, finish. (CT P2=2)

2-4: P1 bacha hai, P3 3 pe aayega. 2-3 P1 chala (Rem=1), 3-4 P1 chala (P1 finish, CT=4). Kyunki P1(1) < P3(3)

Ab 4 pe: P3(BT=3) aur P4(Z) aaye.

Case 1: Agar P4 chota hua to pehle P4 chalega.

4 to 4+Z : P4

4+Z to 7+Z : P3

CT:

P1=4, P2=2, P4=4+Z, P3=7+Z

TAT = CT – AT:

P1=4-0=4

P2=2-1=1

P4=4+Z-4=Z

P3=7+Z-3=4+Z

WT = TAT – BT:

P1=4-3=1

P2=1-1=0

P4=Z-Z=0

P3=4+Z-3=1+Z

Total WT = 1+0+0+1+Z = 2+Z

Avg WT = (2+Z)/4 = 1 (given)=> 2+Z = 4
=> Z = 2

Q7 [GATE 2017 Set-1 : 1M][SRTF Based]
Consider the following CPU processes with arrival times(in milliseconds)

and length of CPU bursts(in milliseconds)as given below:

ProcessArrival TimeBurst Time
P107
P233
P355
P462

If the pre-emptive (SRTF)algorithm is used to schedule the processes, then the average waiting time across all processes is —–miliseconds.

Solution:

Gantt Chart:

  • 0-3: Sirf P1 hai -> P1 chala (Remaining = 7-3 = 4)
  • 3-6: P2 aaya (BT=3) < P1(4) -> P2 chala 3-6, Finish. CT=6
  • 6 pe check: Ready = P1(Rem 4), P3(BT 5), P4(BT 2) -> Sabse chota P4 hai
  • 6-8: P4 chala 6-8, Finish. CT=8
  • 8-12: Ab P1(Rem 4) < P3(5) -> P1 chala 8-12, Finish. CT=12
  • 12-17: P3 chala 12-17, Finish. CT=17

Table:

ProcessATBTCTTAT=CT-ATWT=TAT-BT
P10712125
P233630
P35517127
P462820

Total WT = 5+0+7+0 = 12

Avg WT = 12 / 4 = 3 ms

Answer: 3

Q8 [GATE 2016 Set-2: 2M][SRTF Based]

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.

ProcessArrival TimeBurst Time
P1010
P236
P371
P483

The average turn around tie of these processes is—-miliseconds.

solution:

SRTF Gantt:

  • 0-3: P1 chala, Remaining = 10-3 = 7
  • 3-7: P2 aaya (6) < P1(7) -> P2 chala. P2 Remaining = 2 (kyunki 4 unit chala)
  • 7-8: P3 aaya (1) sabse chota -> P3 chala 7-8, Finish. CT3 = 8
  • 8-10: Ready = P1(7), P2(2), P4(3) -> sabse chota P2 -> P2 chala, Finish. CT2 = 10
  • 10-13: Ready = P1(7), P4(3) -> P4 chota -> P4 chala, Finish. CT4 = 13
  • 13-20: P1 chala, Finish. CT1 = 20
  • Table
ProcessATBTCTTAT=CT-AT
P10102020
P236107
P37181
P483135

Total TAT = 20+7+1+5 = 33

Avg TAT = 33 / 4 = 8.25 milliseconds

Answer: 8.25

Q9[GATE 2014 Set-3: 2M][SRTF Based]

An OS uses shortest remaining time first scheduling algorithms for pre-emptive scheduling of processes. Consider the following set of processes with their arrival times and CPU burst time (in milliseconds):

ProcessArrival TimeBurst Time
P1012
P224
P336
P485

The average waiting time (in milliseconds)of the processes is—

Solution:– SRTF Gantt:

  • 0-2: P1 chala, Rem P1 = 10
  • 2-3: P2 aaya (4) < P1(10) -> P2 chala, Rem P2 = 3
  • 3-6: Ready = P1(10), P2(3), P3(6) -> P2 sabse chota -> P2 chala, Finish. CT2=6
  • 6-8: Ready = P1(10), P3(6) -> P3 chala 2 unit, Rem P3 = 4
  • 8-12: P4 aaya (5). Ready = P1(10), P3(4), P4(5) -> P3 chala, Finish. CT3=12
  • 12-17: Ready = P1(10), P4(5) -> P4 chala, Finish. CT4=17
  • 17-27: P1 chala, Finish. CT1=27

Table

ProcessATBTCTTAT=CT-ATWT=TAT-BT
P1012272715
P224640
P3361293
P4851794

Total WT = 15+0+3+4 = 22

Avg WT = 22 / 4 = 5.5 ms

Answer: 5.5

Q10[GATE 2014 Set-1: 2M][SRTF Based]

Consider the following set of processes that need to be scheduled on a single CPU. All the times are given in milliseconds.

Process NameArrival TimeExecution Time
A06
B32
C54
D76
E103

Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is __.

Solution –

SRTF Gantt:

  • 0-3: Only A -> A chala, Rem A = 3
  • 3-5: B aaya (2) < A(3) -> B chala, Finish. CT_B = 5
  • 5-7: Ready = A(3), C(4) -> A chota -> A chala, Rem A = 1
  • 7-8: Ready = A(1), C(4), D(6) -> A chota -> A chala, Finish. CT_A = 8
  • 8-10: Ready = C(4), D(6) -> C chala 2 unit, Rem C = 2
  • 10-12: Ready = C(2), D(6), E(3) -> C sabse chota -> C chala, Finish. CT_C = 12
  • 12-15: Ready = D(6), E(3) -> E chota -> E chala, Finish. CT_E = 15
  • 15-21: D chala, Finish. CT_D = 21

Table

ProcessATBTCTTAT=CT-AT
A0688
B3252
C54127
D762114
E103155

Total TAT = 8+2+7+14+5 = 36

Avg TAT = 36 / 5 = 7.2 msec

Answer: 7.2

Leave a Comment

Your email address will not be published. Required fields are marked *