CoursifyCoursify

CPU Scheduling Case Study: FCFS vs SJF for a Five-Process Workload

CPU Scheduling Case Study: FCFS vs SJF for a Five-Process Workload

Verified Sources
May 27, 2026

This section analyzes two classic CPU scheduling algorithms—FCFS and SJF—for the following workload, where all processes arrive at time 00 in the order A,B,C,D,EA, B, C, D, E.2

ProcessBurst Time (ms)Priority
A103
B11
C23
D14
E52

Because all processes arrive simultaneously, waiting time depends entirely on execution order, and average waiting time is a standard metric for comparing scheduling quality. For this problem, the priority column is not used, because the question asks only for FCFS and non-preemptive SJF schedules.2

A useful identity is:

Waiting Time=Start TimeArrival Time\text{Waiting Time} = \text{Start Time} - \text{Arrival Time}

Since every arrival time is 00, each process's waiting time is simply its start time.2

A second equivalent relation often used in operating systems is:

Waiting Time=Turnaround TimeBurst Time\text{Waiting Time} = \text{Turnaround Time} - \text{Burst Time}

where turnaround time equals completion time minus arrival time.2

The key theoretical result is that non-preemptive SJF minimizes average waiting time when burst lengths are known in advance for a fixed set of ready processes.2

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time. 2 3

  2. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples. 2 3 4

  3. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF. 2 3 4

Shortest Job First(SJF) Scheduling Algorithm with example | Operating System

Interpretation Assumption

Because the prompt asks for SJF without mentioning preemption, the standard interpretation is non-preemptive SJF. Since all processes arrive at time 00, preemptive and non-preemptive behavior would not differ before the first dispatch unless new arrivals occurred later.2

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time.

  2. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

1. FCFS Scheduling

Under FCFS, processes execute strictly in arrival order: ABCDEA \rightarrow B \rightarrow C \rightarrow D \rightarrow E. Since all processes arrive at the same instant, the given arrival order breaks the tie.

The Gantt chart is:

Time01011131419
ProcessABCDE

Equivalently, the execution intervals are:

  • A:010A: 0 \to 10
  • B:1011B: 10 \to 11
  • C:1113C: 11 \to 13
  • D:1314D: 13 \to 14
  • E:1419E: 14 \to 19

For FCFS, the waiting times are the start times:

ProcessStart TimeWaiting Time
A00
B1010
C1111
D1313
E1414

Thus,

Average Waiting TimeFCFS=0+10+11+13+145=485=9.6 ms\text{Average Waiting Time}_{FCFS} = \frac{0+10+11+13+14}{5} = \frac{48}{5} = 9.6 \text{ ms}

This illustrates the classic FCFS weakness: short jobs may wait behind a long job, increasing the mean waiting time.2

Footnotes

  1. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF. 2

  2. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time. 2

How to Build the FCFS Gantt Chart

  1. 1
    Step 1

    Because every process arrives at time 00, the given order A,B,C,D,EA, B, C, D, E is used directly.

    Footnotes

    1. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF.

  2. 2
    Step 2

    Process AA runs from time 00 to time 1010 because its burst time is 1010 ms.

  3. 3
    Step 3

    After AA finishes, BB runs from time 1010 to time 1111.

  4. 4
    Step 4

    Next, CC runs from time 1111 to time 1313.

  5. 5
    Step 5

    Then, DD runs from time 1313 to time 1414.

  6. 6
    Step 6

    Finally, EE runs from time 1414 to time 1919.

  7. 7
    Step 7

    Since arrival time is 00 for every process, each waiting time equals the point where that process begins execution.

    Footnotes

    1. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

2. SJF Scheduling

In non-preemptive SJF, the ready process with the smallest burst time is selected first.2 With all processes available at time 00, we sort by burst length:

  • B=1B = 1
  • D=1D = 1
  • C=2C = 2
  • E=5E = 5
  • A=10A = 10

When two processes have equal burst times, a common tie-break rule is FCFS among tied processes.2 Since BB arrived before DD, the SJF order is:

BDCEAB \rightarrow D \rightarrow C \rightarrow E \rightarrow A

The Gantt chart is:

Time0124919
ProcessBDCEA

Execution intervals:

  • B:01B: 0 \to 1
  • D:12D: 1 \to 2
  • C:24C: 2 \to 4
  • E:49E: 4 \to 9
  • A:919A: 9 \to 19

Waiting times:

ProcessStart TimeWaiting Time
B00
D11
C22
E44
A99

So,

Average Waiting TimeSJF=0+1+2+4+95=165=3.2 ms\text{Average Waiting Time}_{SJF} = \frac{0+1+2+4+9}{5} = \frac{16}{5} = 3.2 \text{ ms}

This is substantially smaller than FCFS, which matches the standard result that SJF is optimal for minimizing average waiting time when burst durations are known.2

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time. 2

  2. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples. 2 3

  3. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF.

How to Build the SJF Gantt Chart

  1. 1
    Step 1

    At time 00, every process is already in the ready queue, so the scheduler can compare all burst times immediately.

    Footnotes

    1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time.

  2. 2
    Step 2

    Order the processes by ascending CPU burst: 1,1,2,5,101, 1, 2, 5, 10.

  3. 3
    Step 3

    Processes BB and DD both have burst time 11, so BB goes first because it arrived earlier in the given order.

    Footnotes

    1. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

  4. 4
    Step 4

    Mark B:01B: 0\to1, D:12D: 1\to2, C:24C: 2\to4, E:49E: 4\to9, and A:919A: 9\to19.

  5. 5
    Step 5

    Use each start time as the waiting time because all arrival times are 00.

  6. 6
    Step 6

    Add the waiting times and divide by 55 to obtain 3.23.2 ms.

Average Waiting Time Comparison

Lower values indicate better average queueing performance for this workload.2

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time.

  2. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

Fast Exam Shortcut

If all arrival times are 00, the waiting time of each process is just the sum of burst times of all processes scheduled before it. This makes Gantt-chart calculations much faster.2

Footnotes

  1. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

  2. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF.

Common Mistake

Do not use the priority column here. Priority scheduling is a different algorithm. For this question, only FCFS and SJF determine execution order.2

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time.

  2. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF.

OrderABCDE
Burst101215
Start010111314
Wait010111314

Average waiting time =9.6= 9.6 ms.

Chronological Execution Comparison

Start with A

FCFS

The long 1010 ms job AA runs first because it arrived first, causing all shorter jobs to wait."

Footnotes

  1. CPU Scheduling in Operating Systems - GeeksforGeeks - Definitions of burst time, turnaround time, waiting time, and a comparison of FCFS and SJF.

Short jobs delayed

FCFS

Processes BB, CC, and DD incur waiting times of 1010, 1111, and 1313 ms respectively."

Shortest jobs first

SJF

Processes with burst times 1,1,21, 1, 2 run before the longer jobs, reducing queue delay.2"

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time.

  2. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

Lower average wait

SJF

The computed average waiting time drops from 9.69.6 ms to 3.23.2 ms."

Worked Clarifications and Edge Cases

Final Answer

The required Gantt charts are:

FCFS

01011131419
ABCDE

SJF

0124919
BDCEA

Average waiting times:

FCFS=9.6 ms\text{FCFS} = 9.6 \text{ ms} SJF=3.2 ms\text{SJF} = 3.2 \text{ ms}

Therefore, SJF results in the minimum average waiting time.2

Footnotes

  1. Operating Systems: CPU Scheduling - Course notes explaining FCFS, SJF, Gantt charts, and the optimality of SJF for minimizing average waiting time.

  2. Shortest Job First or SJF CPU Scheduling - GeeksforGeeks - Overview of non-preemptive SJF, waiting-time formulas, and worked Gantt-chart examples.

Knowledge Check

Question 1 of 5
Q1Single choice

What is the FCFS execution order for the given processes when all arrive at time 00?

Chat with Kiro