The first process runs another process should wait for its turn. Below is the Brief description or Q&A of the FCFS Non-Preemptive scheduling algorithm.
First Come First Served (FCFS) is a Non-Preemptive scheduling algorithm for process execution in an operating system and easy to understand and has poor performance (waiting time is higher), If the first process takes more time for execution than until finish first process rest of the process has to wait.
Turn Around Time = Completion Time – Arrival Time
With the help of this formula, we can calculate a Turn Around Time of all processes in Queue.
Waiting Time = Turn Around Time – Burst Time
This formula is used for calculating the waiting time for the rest of the process.
FCFS Scheduling Program in C++ With Arrival Time And Gantt Chart
#include <stdio.h>
#include <string.h>
int strToint(char[]);
int main()
{
/*FCFS Scheduling Program in C++ With Arrival Time And Gantt Chart*/
cout << "=====================================";
cout << "\nVisit - www.programmingwithbasics.com";
cout << "\n=====================================";
while (1)
{
char str[10];
int intNum;
printf("\n\nEnter Integer Number: ");
scanf("%s", str);
intNum = strToint(str);
if (intNum == 0)
{
printf("\nEnter The Number Not String\n\n");
}
else
{
printf("\n\nEquivalent Integer Value: %d", intNum);
}
}
return 0;
}
int strToint(char str[])
{
int i = 0, sum = 0;
while (str[i] != '\0')
{
if (str[i] < 48 || str[i] > 57)
{
printf("\n\nCan't Convert Into Integer");
return 0;
}
else
{
sum = sum *10 + (str[i] - 48);
i++;
}
}
return sum;
}
return sum;
}
First Come First Serve Scheduling
- What is the First Come First Serve (FCFS) Scheduling?
- How to Calculate Turn-Around Time?
- How to Calculate Waiting Time?
- First Come First Serve Example
What is the First Come First Served (FCFS) Scheduling?
First Come First Served (FCFS) is a Non-Preemptive scheduling algorithm for process execution in an operating system and easy to understand and has poor performance (waiting time is higher), If the first process takes more time for execution than until finish first process rest of the process has to wait.
How to Calculate Turn-Around Time?
Turn Around Time = Completion Time – Arrival Time
With the help of this formula, we can calculate a Turn Around Time of all processes in Queue.
How to Calculate Waiting Time?.
Waiting Time = Turn Around Time – Burst Time
This formula is used for calculating the waiting time for the rest of the process.
FCFS Example
We are taking 5 processes whose CBT, or Burst Time Is 4, 9, 8, 3, and 7 respectively and the output is given below.
Enter The Total Number of Processes: 5
Enter CBT of Process:
4
9
8
3
7
=======================
Gantt. Chart
=======================
[P1] [P2] [P3] [P4] [P5]
--------------------------------------
0 4 13 21 24
==================================
Process CBT Waiting Time Turn Around Time
==================================
[p1] 4 0 4
[p2] 9 4 13
[p3] 8 13 21
[p4] 3 21 24
[p5] 7 24 31
Average Awating Time: 12.4
Average Turn Around Time: 18.6
Enter The Total Number of Processes: 5
Enter CBT of Process:
4
9
8
3
7
=======================
Gantt. Chart
=======================
[P1] [P2] [P3] [P4] [P5]
--------------------------------------
0 4 13 21 24
==================================
Process CBT Waiting Time Turn Around Time
==================================
[p1] 4 0 4
[p2] 9 4 13
[p3] 8 13 21
[p4] 3 21 24
[p5] 7 24 31
Average Awating Time: 12.4
Average Turn Around Time: 18.6
0 Comments: