Bird
Raised Fist0
Operating Systemsknowledge~10 mins

FCFS (First Come First Served) in Operating Systems - Interactive Code Practice

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
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the scheduling algorithm that executes processes in the order they arrive.

Operating Systems
algorithm = "[1]"
Drag options to blanks, or click blank then click option'
ARound Robin
BShortest Job First
CFCFS
DPriority Scheduling
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing FCFS with Round Robin or Priority Scheduling.
Choosing an algorithm that does not follow arrival order.
2fill in blank
medium

Complete the code to calculate the waiting time for the first process in FCFS scheduling.

Operating Systems
waiting_time[0] = [1]
Drag options to blanks, or click blank then click option'
Aarrival_time[0]
Bburst_time[0]
Ccompletion_time[0]
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting waiting time equal to burst time or arrival time.
Confusing waiting time with completion time.
3fill in blank
hard

Fix the error in the code to compute the waiting time for process i in FCFS scheduling.

Operating Systems
waiting_time[i] = completion_time[i-1] [1] arrival_time[i]
Drag options to blanks, or click blank then click option'
A-
B/
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction.
Using multiplication or division which are incorrect here.
4fill in blank
hard

Fill both blanks to compute the completion time for process i in FCFS scheduling.

Operating Systems
completion_time[i] = completion_time[i-1] [1] burst_time[i] [2] 0
Drag options to blanks, or click blank then click option'
A+
B-
Cif
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition.
Not using a condition to handle the first process.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each process to its waiting time if waiting time is positive.

Operating Systems
waiting_times = [1]: [2] for [3] in processes if waiting_time[process] > 0
Drag options to blanks, or click blank then click option'
Aprocess
Bwaiting_time[process]
Cprocesses
Dwaiting_time
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names.
Not filtering processes with positive waiting time.

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