FCFS
stands for (First Come First Serve), is one of the simplest
scheduling algorithms in operating system. It schedules
processes based on their arrival time.The process Which comes first according to the arrival time
executes
first and all other process wait in a queue untill the running process completes its work.
- Step 1: List all the processes and their arrival times in the order they arrive.
- Step 2: Assign CPU to the process that arrives first and continue until it completes execution.
- Step 3: After completion, check if the next process is ready to execute.
- Step 4: Repeat the process for all other processes in the queue based on arrival time.
-
Step 5: Calculate the waiting time for each process as:
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
-
Step 6: Calculate the turnaround time for each process as:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Step 7: Sum up the total waiting time and turnaround time for performance evaluation.
Advantages | Disadvantages |
---|---|
Simple and easy to implement. | Long waiting times for processes with long burst times ( convoy effect ). |
No starvation, as every process gets a turn. | Poor response time for time-critical processes. |
Fair for long-running processes. | Not optimal for a multi-user or real-time system. |
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
This set includes 17 questions based on the First Come First Served (FCFS) process scheduling algorithm. Each problem is organized in a tabular format and comes with a detailed solution, including the Gantt chart, average turnaround time (TAT), and average waiting time (WT).
Exercise 1 : Calculate TAT, WT, and Completion Time Using FCFS Scheduling (Based on the Table Below)
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 2 |
P2 | 2 | 4 |
P3 | 4 | 3 |
P4 | 5 | 1 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 2 | 2 | 0 |
P2 | 6 | 4 | 0 |
P3 | 9 | 5 | 2 |
P4 | 10 | 5 | 4 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (2 + 4 + 5 + 5) / 4 = 16 / 4 = 4
units
Average Waiting Time = (0 + 0 + 2 + 4) / 4 = 6 / 4 = 1.5 units
Exercise 2 : Determine Average TAT, WT, and Completion Time Using FCFS Algorithm with Given Processes
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 1 | 5 |
P2 | 2 | 3 |
P3 | 3 | 6 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 6 | 5 | 0 |
P2 | 9 | 7 | 4 |
P3 | 15 | 12 | 6 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (5 + 7 + 12) / 3 = 24 / 3 = 8 units
Average Waiting Time = (0 + 4 + 6) / 3 = 10 / 3 = 3.33 units
Exercise 3 : Given 4 processes with arrival and burst times, calculate the Gantt chart, waiting time, and turnaround time using FCFS?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 1 | 2 |
P2 | 3 | 4 |
P3 | 5 | 3 |
P4 | 6 | 2 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 3 | 2 | 0 |
P2 | 7 | 4 | 0 |
P3 | 10 | 5 | 2 |
P4 | 12 | 6 | 4 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (2 + 4 + 5 + 6) / 4 = 17 / 4 = 4.25
units
Average Waiting Time = (0 + 0 + 2 + 4) / 4 = 6 / 4 = 1.5 units
Exercise 4 : find the average Turn Around Time and Waiting Time of following processes using FCFS(FIRST COME FIRST SERVED) process scheduling algorithm?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 4 |
P2 | 1 | 3 |
P3 | 2 | 1 |
P4 | 3 | 2 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 4 | 4 | 0 |
P2 | 7 | 6 | 3 |
P3 | 8 | 6 | 5 |
P4 | 10 | 7 | 5 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (4 + 6 + 6 + 7) / 4 = 23 / 4 = 5.75
units
Average Waiting Time = (0 + 3 + 5 + 5) / 4 = 13 / 4 = 3.25
units
Exercise 5 : Given 4 processes with arrival and burst times, calculate the Gantt chart waiting time and turnaround time using FCFS
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 2 | 3 |
P2 | 4 | 1 |
P3 | 6 | 2 |
P4 | 7 | 4 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 5 | 3 | 0 |
P2 | 6 | 2 | 1 |
P3 | 8 | 2 | 0 |
P4 | 12 | 5 | 1 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (3 + 2 + 2 + 5) / 4 = 12 / 4 = 3
units
Average Waiting Time = (0 + 1 + 0 + 1) / 4 = 2 / 4 = 0.5 units
Exercise 6 : find the average Turn Around Time and Waiting Time of following processes using FCFS(FIRST COME FIRST SERVED) process scheduling algorithm?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 6 |
P2 | 2 | 3 |
P3 | 4 | 5 |
P4 | 6 | 2 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 6 | 6 | 0 |
P2 | 9 | 7 | 4 |
P3 | 14 | 10 | 5 |
P4 | 16 | 10 | 8 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (6 + 7 + 10 + 10) / 4 = 33 / 4 =
8.25 units
Average Waiting Time = (0 + 4 + 5 + 8) / 4 = 17 / 4 = 4.25
units
Exercise 7 find the average Turn Around Time and Waiting Time of following processes using FCFS(FIRST COME FIRST SERVED) process scheduling algorithm?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 7 |
P2 | 1 | 5 |
P3 | 2 | 3 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 7 | 7 | 0 |
P2 | 12 | 11 | 6 |
P3 | 15 | 13 | 10 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (7 + 11 + 13) / 3 = 31 / 3 = 10.33
units
Average Waiting Time = (0 + 6 + 10) / 3 = 16 / 3 = 5.33 units
Exercise 8 : find the average Turn Around Time and Waiting Time of following processes using FCFS(FIRST COME FIRST SERVED) process scheduling algorithm?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 3 | 2 |
P2 | 5 | 4 |
P3 | 7 | 3 |
P4 | 9 | 1 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 5 | 2 | 0 |
P2 | 9 | 4 | 0 |
P3 | 12 | 5 | 2 |
P4 | 13 | 4 | 3 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (2 + 4 + 5 + 4) / 4 = 15 / 4 = 3.75
units
Average Waiting Time = (0 + 0 + 2 + 3) / 4 = 5 / 4 = 1.25
units
Exercise 9 : find the average Turn Around Time and Waiting Time of following processes using FCFS(FIRST COME FIRST SERVED) process scheduling algorithm?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 4 |
P2 | 1 | 5 |
P3 | 3 | 3 |
P4 | 5 | 2 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 4 | 4 | 0 |
P2 | 9 | 8 | 3 |
P3 | 12 | 9 | 6 |
P4 | 14 | 9 | 7 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (4 + 8 + 9 + 9) / 4 = 30 / 4 = 7.5
units
Average Waiting Time = (0 + 3 + 6 + 7) / 4 = 16 / 4 = 4 units
Question 10 : Consider 3 processes arriving at time intervals P1, P2, P3. Compute the average waiting time and turnaround time using FCFS scheduling?
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 4 |
P2 | 2 | 3 |
P3 | 4 | 2 |
Solution
Gantt Chart
Process | Completion Time | Turn Around Time | Waiting Time |
---|---|---|---|
P1 | 4 | 4 | 0 |
P2 | 7 | 5 | 2 |
P3 | 9 | 5 | 3 |
Formulas:
- Average Turn Around Time (Average TAT) = Σ(TAT) / Number of Processes
- Average Waiting Time (Average WT) = Σ(WT) / Number of Processes
Average Turn Around Time = (4 + 5 + 5) / 3 = 14 / 3 = 4.67
units
Average Waiting Time = (0 + 2 + 3) / 3 = 5 / 3 = 1.67 units