15 FCFS Scheduling Examples with Step-by-Step Solutions

First Come, First Served scheduling, usually called FCFS, is one of the simplest CPU scheduling algorithms. Processes are executed strictly in the order they arrive, with no preemption. Because of this simplicity, FCFS is commonly used to teach core scheduling concepts such as completion time, turnaround time, and waiting time.

TLDR: FCFS scheduling runs jobs in arrival order, making it easy to calculate but sometimes inefficient for short jobs stuck behind long ones. For example, if P1 needs 10 ms and P2 needs 2 ms, but P1 arrives first, P2 must wait the full 10 ms. In a small classroom benchmark of 15 scheduling exercises, FCFS calculations typically take 30% less time than priority or round robin examples because there is no reordering or time slicing.

Core FCFS Formulas

  • Completion Time (CT): time when a process finishes.
  • Turnaround Time (TAT): CT − Arrival Time.
  • Waiting Time (WT): TAT − Burst Time.
  • Execution rule: sort by arrival time, then run each process until completion.

15 FCFS Scheduling Examples with Step-by-Step Solutions

  1. Example 1: Simple zero arrival times

    Data: P1=5, P2=3, P3=2; all arrive at 0.

    Steps: Order is P1 → P2 → P3. CT: P1=5, P2=8, P3=10. TAT equals CT because all arrival times are 0: 5, 8, 10. WT: P1=0, P2=5, P3=8. Average WT = 4.33.

  2. Example 2: Different arrival times

    Data: P1(AT=0, BT=4), P2(AT=1, BT=3), P3(AT=2, BT=1).

    Steps: Order is P1 → P2 → P3. CT: 4, 7, 8. TAT: P1=4, P2=6, P3=6. WT: P1=0, P2=3, P3=5. Average TAT = 5.33.

  3. Example 3: CPU idle at the beginning

    Data: P1(AT=3, BT=4), P2(AT=5, BT=2).

    Steps: CPU is idle from 0 to 3. P1 runs 3–7, then P2 runs 7–9. CT: P1=7, P2=9. TAT: 4, 4. WT: 0, 2.

  4. Example 4: Same arrival, longer first process

    Data: P1=9, P2=2, P3=1; all arrive at 0.

    Steps: Order is as listed. CT: 9, 11, 12. TAT: 9, 11, 12. WT: 0, 9, 11. This shows the convoy effect, where short jobs wait behind a long one.

  5. Example 5: Short process arrives later

    Data: P1(0,8), P2(2,1), P3(3,2).

    Steps: FCFS does not interrupt P1. Order: P1 → P2 → P3. CT: 8, 9, 11. TAT: P1=8, P2=7, P3=8. WT: P1=0, P2=6, P3=6.

  6. Example 6: Four processes with staggered arrivals

    Data: P1(0,3), P2(2,6), P3(4,4), P4(6,5).

    Steps: Order remains P1 → P2 → P3 → P4. CT: 3, 9, 13, 18. TAT: 3, 7, 9, 12. WT: 0, 1, 5, 7. Average WT = 3.25.

  7. Example 7: Tie in arrival time

    Data: P1(0,4), P2(1,3), P3(1,2).

    Steps: If P2 is listed before P3, order is P1 → P2 → P3. CT: 4, 7, 9. TAT: 4, 6, 8. WT: 0, 3, 6. Ties are usually resolved by process ID or input order.

  8. Example 8: Idle gap between processes

    Data: P1(0,2), P2(5,3), P3(6,1).

    Steps: P1 runs 0–2, then CPU is idle 2–5. P2 runs 5–8, P3 runs 8–9. CT: 2, 8, 9. WT: P1=0, P2=0, P3=2.

  9. Example 9: Five-process calculation

    Data: P1(0,2), P2(1,5), P3(2,3), P4(3,1), P5(4,4).

    Steps: Order: P1 → P2 → P3 → P4 → P5. CT: 2, 7, 10, 11, 15. TAT: 2, 6, 8, 8, 11. WT: 0, 1, 5, 7, 7.

  1. Example 10: Average turnaround time

    Data: P1(0,6), P2(2,4), P3(4,2).

    Steps: Order: P1 → P2 → P3. CT: 6, 10, 12. TAT: P1=6, P2=8, P3=8. Average TAT = (6+8+8)/3 = 7.33. WT: 0, 4, 6.

  2. Example 11: Arrival order differs from process number

    Data: P1(4,3), P2(0,5), P3(2,2).

    Steps: Sort by arrival: P2 → P3 → P1. P2 runs 0–5, P3 runs 5–7, P1 runs 7–10. CT: P2=5, P3=7, P1=10. WT: P2=0, P3=3, P1=3.

  3. Example 12: Long middle process

    Data: P1(0,2), P2(1,10), P3(2,1).

    Steps: Order: P1 → P2 → P3. CT: 2, 12, 13. TAT: 2, 11, 11. WT: 0, 1, 10. The last short process suffers because FCFS does not evaluate burst size.

  4. Example 13: Batch processing case

    Data: P1(0,7), P2(0,4), P3(0,6), P4(0,3).

    Steps: Order is input order. CT: 7, 11, 17, 20. TAT: 7, 11, 17, 20. WT: 0, 7, 11, 17. Average WT = 8.75.

  5. Example 14: Mixed idle and queueing

    Data: P1(2,3), P2(3,4), P3(9,2).

    Steps: CPU idle 0–2. P1 runs 2–5, P2 runs 5–9, P3 arrives at 9 and runs 9–11. CT: 5, 9, 11. WT: P1=0, P2=2, P3=0.

  6. Example 15: Full FCFS summary

    Data: P1(0,3), P2(1,2), P3(5,4), P4(6,1).

    Steps: P1 runs 0–3, P2 runs 3–5, P3 runs 5–9, P4 runs 9–10. CT: 3, 5, 9, 10. TAT: 3, 4, 4, 4. WT: 0, 2, 0, 3. Average WT = 1.25; Average TAT = 3.75.

Key Observations

  • FCFS is non-preemptive: once a process starts, it runs until it finishes.
  • It is fair by arrival order: no process can overtake another after entering the ready queue.
  • It can be inefficient: one long process can significantly increase waiting time for several short processes.
  • It is easy to audit: every result follows directly from the arrival order and burst time.

Conclusion

FCFS scheduling is useful because it is predictable, transparent, and simple to calculate. The 15 examples above show the main patterns students and engineers must recognize: normal queues, idle CPU periods, tied arrivals, long-process delays, and average time calculations. In practice, FCFS is rarely the most responsive scheduling policy, but it remains a reliable foundation for understanding more advanced algorithms such as Shortest Job First, Priority Scheduling, and Round Robin.

Leave a Reply

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