Bird
Raised Fist0
Operating Systemsknowledge~10 mins

FCFS (First Come First Served) in Operating Systems - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - FCFS (First Come First Served)
Processes arrive in order
Queue processes by arrival time
Pick first process in queue
Run process to completion
Remove process from queue
Repeat for next process
All done
FCFS schedules processes in the order they arrive, running each to completion before starting the next.
Execution Sample
Operating Systems
Processes = ['P1', 'P2', 'P3']
Arrival = [0, 2, 4]
Burst = [5, 3, 1]
Schedule by arrival
Run each fully in order
This example shows three processes arriving at different times, scheduled and run one after another in arrival order.
Analysis Table
StepCurrent TimeProcess SelectedProcess Start TimeProcess End TimeQueue State
10P105[P1]
25P258[P2, P3]
38P389[P3]
49NoneN/AN/A[]
💡 All processes completed; queue is empty.
State Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
Current Time05899
Queue[P1][P2, P3][P3][][]
Process SelectedNoneP1P2P3None
Key Insights - 2 Insights
Why does the CPU wait if the next process hasn't arrived yet?
In FCFS, the CPU is idle if no process has arrived by the current time. For example, if the next process arrives after the current time, the CPU waits until that arrival.
Can a process be interrupted once it starts?
No, FCFS runs each process fully until it finishes before starting the next one, as shown by continuous start and end times in execution_table rows.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at Step 2. What is the current time when process P2 starts?
A2
B5
C8
D0
💡 Hint
Check the 'Process Start Time' column for Step 2 in execution_table.
At which step does the queue become empty?
AStep 3
BStep 2
CStep 4
DStep 1
💡 Hint
Look at the 'Queue State' column in execution_table to see when it becomes [].
If process P3 arrived earlier at time 3, how would that affect the queue at Step 2?
ANo change; queue stays the same
BP3 would be ahead of P2 in the queue
CP3 would run before P1
DP3 would be removed from the queue
💡 Hint
FCFS orders by arrival time; check variable_tracker for queue order changes.
Concept Snapshot
FCFS (First Come First Served):
- Processes run in order of arrival.
- Each process runs fully before next starts.
- Simple, non-preemptive scheduling.
- Can cause waiting if early processes are long.
- Easy to understand and implement.
Full Transcript
FCFS scheduling runs processes in the order they arrive. The CPU picks the first process in the queue and runs it fully before moving to the next. If no process has arrived, the CPU waits. This method is simple but can cause delays if early processes take long. The execution table shows how current time advances as each process runs, and the queue shrinks until empty.

Practice

(1/5)
1. What does FCFS (First Come First Served) scheduling mean in operating systems?
easy
A. Processes with the shortest time are handled first.
B. Processes are handled in the order they arrive.
C. Processes are handled randomly.
D. Processes with the highest priority are handled first.

Solution

  1. Step 1: Understand FCFS concept

    FCFS means tasks are processed in the order they come, like a queue.
  2. Step 2: Compare options

    Only Processes are handled in the order they arrive. describes this order-based processing correctly.
  3. Final Answer:

    Processes are handled in the order they arrive. -> Option B
  4. Quick Check:

    FCFS = Order of arrival [OK]
Hint: Remember: FCFS is like waiting in line [OK]
Common Mistakes:
  • Confusing FCFS with priority scheduling
  • Thinking shortest tasks go first
  • Assuming random order
2. Which of the following is the correct way to describe FCFS scheduling?
easy
A. Processes are scheduled in the order they arrive without preemption.
B. Processes are scheduled based on their priority levels.
C. Processes are scheduled by shortest remaining time first.
D. Processes are scheduled randomly to balance load.

Solution

  1. Step 1: Identify FCFS scheduling traits

    FCFS schedules tasks in arrival order and does not interrupt running tasks.
  2. Step 2: Match options to traits

    Processes are scheduled in the order they arrive without preemption. correctly states no preemption and order of arrival.
  3. Final Answer:

    Processes are scheduled in the order they arrive without preemption. -> Option A
  4. Quick Check:

    FCFS = Arrival order + no preemption [OK]
Hint: FCFS runs tasks fully in arrival order [OK]
Common Mistakes:
  • Mixing FCFS with priority or shortest job scheduling
  • Assuming tasks can be interrupted
  • Thinking scheduling is random
3. Given three processes arriving at times 0, 2, and 4 with burst times 5, 3, and 1 respectively, what is the completion time of the second process using FCFS?
medium
A. 10
B. 5
C. 8
D. 9

Solution

  1. Step 1: Calculate completion of first process

    Process 1 arrives at 0 and runs for 5 units, finishing at time 5.
  2. Step 2: Calculate completion of second process

    Process 2 arrives at 2 but waits until process 1 finishes at 5, then runs for 3 units, finishing at 8.
  3. Final Answer:

    8 -> Option C
  4. Quick Check:

    Process 2 finishes at 5+3=8 [OK]
Hint: Add burst times in arrival order [OK]
Common Mistakes:
  • Starting second process at its arrival time instead of after first finishes
  • Adding arrival times incorrectly
  • Ignoring waiting time
4. A student wrote this FCFS scheduling code but it gives wrong completion times. What is the likely error?
processes = [(0, 4), (1, 3), (2, 1)]  # (arrival, burst)
completion = []
current_time = 0
for arrival, burst in processes:
    if arrival > current_time:
        current_time = arrival
    completion.append(current_time)
    current_time += burst
print(completion)
medium
A. Not updating current_time after appending completion time.
B. Using a list instead of a queue for processes.
C. Not considering arrival time when updating current_time.
D. Appending completion time before updating current_time.

Solution

  1. Step 1: Analyze code logic

    Completion time is appended before current_time is updated with burst time, causing wrong values.
  2. Step 2: Identify correct order

    We must update current_time by adding burst before appending completion time to reflect actual finish time.
  3. Final Answer:

    Appending completion time before updating current_time. -> Option D
  4. Quick Check:

    Update time before recording completion [OK]
Hint: Update current time before saving completion [OK]
Common Mistakes:
  • Appending completion time too early
  • Ignoring arrival time adjustments
  • Confusing process order
5. In an FCFS system, three processes arrive at times 0, 1, and 2 with burst times 4, 2, and 6. If the first process takes longer than expected and runs for 8 units instead of 4, how does this affect the waiting time of the third process?
hard
A. The third process waits longer because the first process delays the queue.
B. The third process waiting time remains the same.
C. The third process starts earlier due to the delay.
D. The third process is skipped and runs immediately.

Solution

  1. Step 1: Understand FCFS impact of longer burst

    FCFS runs processes fully in arrival order, so a longer first process delays all others.
  2. Step 2: Analyze waiting time effect on third process

    The third process must wait until the first and second finish, so longer first process increases its waiting time.
  3. Final Answer:

    The third process waits longer because the first process delays the queue. -> Option A
  4. Quick Check:

    Longer first task = longer wait for later tasks [OK]
Hint: Long first task delays all later tasks [OK]
Common Mistakes:
  • Assuming later tasks start earlier
  • Ignoring impact of burst time changes
  • Thinking FCFS skips tasks