FCFS Scheduling Algorithms and Program in C with Gantt chart

FCFS Scheduling Algorithms and Program in C with Gantt chart

First Come First-Served Scheduling (FCFS)
Criteria: Arrival time
Mode: Non Primitive

1. First Come First-Served Scheduling with Arrival time 

Process No Arrival Time (AT) Brust time (BT)/ CPU Time Complication Time(CT) Turn Around Time(TAT) Waiting time(WT) Response Time(RT)
P1 0 3 3 3 0 0
P2 2 3 6 4 1 1
P3 6 4 10 4 0 0
P4 7 5 15 8 3 3

Gantt Chart
P1 P2 P3 P4
0              3                6             10             15

Here,
Turn Around Time(TAT) = Complication Time(CT) -  Arrival Time (AT)
Waiting time(WT) = Turn Around Time(TAT) - Brust time (BT)
Response Time(RT) = When first come to the process in Gantt Chart - Arrival Time (AT)


2. First Come First-Served Scheduling without Arrival time
Process No Brust time (BT)/ CPU Time Complication Time(CT) Turn Around Time(TAT) Waiting time(WT) Response Time(RT)
P1 2 2 2 0 0
P2 6 8 8 2 2
P3 3 11 11 8 8
P4 8 19 19 11 11

Gantt Chart
P1 P2 P3 P4
0              2                8              11            19

Here,
Turn Around Time(TAT) = Complication Time(CT) -  Arrival Time (AT)
Waiting time(WT) = Turn Around Time(TAT) - Brust time (BT)
Response Time(RT) = When first come to the process in Gantt Chart - Arrival Time (AT)

----------------------------x -------------------------
1. First Come First Serve without Arrival time in C programming language code
Here,


#include<stdio.h>

int main(){
    int n, processor[10],cpu[10],w[10],t[10],i,j,sum_w=0,sum_t=0;
    float avg_w,avg_t;
    printf("Enter The numver of processor 	");
    scanf("%d",&n);

       for(i=0; i<n; i++)
    {
        printf("Enter cpu time of P%d	",i+1);
        scanf("%d",&cpu[i]);
        printf("
");
    }

    w[0]=0;
    for(i=1; i<n; i++)
    {
        w[i]=w[i-1]+cpu[i-1];
        sum_w=sum_w+w[i];
    }

    for(i=0; i<n; i++)
    {
        t[i]=w[i]+cpu[i];
        sum_t=sum_t+t[i];
    }

    avg_w=(float)sum_w/n;
    avg_t=(float)sum_t/n;
    printf("
 Avg waiting =%.2f",avg_w);
    printf("
 Avg Turn Around Time =%.2f
",avg_t);

printf("Process		CPU Time 	waiting 	Turn around
");

for(i=0; i<n; i++)
{
    printf(" P%d		%d		%d		%d
",i+1,cpu[i],w[i],t[i]);
}

printf("

");
printf("******Gantt Chart******
");
printf("|");
for(i=0; i<n; i++)
{
    printf("  P%d  |",i+1);
}
printf("
0");
for(i=0; i<n; i++)
{
    printf("     %d",t[i]);
}

}



2. First Come First Serve with Arrival time in C programming language code
Here,

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int n,
        process[10],cpu[10],w[10],t[10],At[10],sum_w=0,sum_t=0,i,j,temp=0,temp1=0;
    float avg_w, avg_t;
    printf("enter the number of process
");
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        printf("Enter cpu time of P%d:",i+1);
        scanf("%d", &cpu[i]);
        printf("
");
    }
    process[0]=1;
    for(i=1; i<n; i++)
    {
        process[i]=i+1;
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(cpu[i]>cpu[j])
            {
                temp=cpu[i];
                cpu[i]=cpu[j];
                cpu[j]=temp;
                temp1=process[i];
                process[i]=process[j];
                process[j]=temp1;
            }
        }
    }
    w[0]=0;
    for(i=1; i<n; i++)
    {
        w[i]=w[i-1]+cpu[i-1];
    }
    for(i=0; i<n; i++)
    {
        sum_w=sum_w+w[i];
    }

    for(i=0; i<n; i++)
    {
        t[i]=w[i]+cpu[i];
        sum_t=sum_t+t[i];
    }
    printf("Process--CPU_time--Wait--Turnaround
");
    for(i=0; i<n; i++)
    {
        printf(" P%d   	%d   	%d  	%d",process[i],cpu[i],w[i],t[i]);
        printf("
");
    }
    avg_w=(float)sum_w/n;
    avg_t=(float)sum_t/n;
    printf("average waiting time=%.2f
",avg_w);
    printf("average turnaround time=%.2f
",avg_t);
    cout<<"
";
    cout<<"===============================GrandChart====================================="<<endl<<"
";
    printf("|");
    for(i=0; i<n; i++)
    {
        printf(" P%d |",process[i]);
    }
    printf("
0");
    for(i=0; i<n; i++)
    {
        printf("   %d",t[i]);
    }
}



Thank You...
first come first serve scheduling algorithm, first come first serve scheduling example, first come first serve scheduling program in c, fcfs calculator, fcfs scheduling program in c, fcfs example with solution, first come first serve scheduling program in c with gantt chart, fcfs scheduling program in c with arrival time, cpu scheduling algorithms in c source code, fcfs scheduling program in c with arrival time and gantt chart, how to make a gantt chart in c, fcfs scheduling program in c with arrival time, first come first serve scheduling gantt chart, fcfs scheduling program in c without arrival time, fcfs scheduling program in c with arrival time and gantt chart, fcfs scheduling example, fcfs scheduling algorithm, fcfs scheduling program in c, fcfs scheduling calculator, fcfs scheduling program in c, fcfs non preemptive scheduling example, fcfs example with solution