What Is FCFS Scheduling Algorithm in Operating System ?
FCFS (First Come First Serve) is one of the simplest scheduling algorithms in operating system. It schedules processes based on their arrival time. The process that arrives first gets executed first, and others wait in a queue.
Method to Solve FCFS Scheduling Algorithm
- 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 and Disadvantages of FCFS Scheduling
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. |
Question 1 : 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 | 2 | 3 |
P3 | 4 | 2 |
Solution
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 2
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 | 1 | 5 |
P2 | 2 | 3 |
P3 | 3 | 6 |
Solution
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 3
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 | 1 | 2 |
P2 | 3 | 4 |
P3 | 5 | 3 |
P4 | 6 | 2 |
Solution
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 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
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 5
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 | 2 | 3 |
P2 | 4 | 1 |
P3 | 6 | 2 |
P4 | 7 | 4 |
Solution
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 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
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 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
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 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
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
Question 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
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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
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 | 2 |
P2 | 2 | 4 |
P3 | 4 | 3 |
P4 | 5 | 1 |
Solution
Formulas:
- Turn Around Time (TAT) = Completion Time (CT) - Arrival Time (AT)
- Waiting Time (WT) = Turn Around Time (TAT) - Burst Time (BT)
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