You'll get reports of electrical and computer engineering here.

Thursday, September 19, 2019

FCFS CPU Scheduling Algorithm

Problem No: 01

Name of the problem: FCFS CPU Scheduling Algorithm

Theory: First come, first served (FCFS) is an operating system process scheduling algorithm and a network routing management mechanism that automatically executes queued requests and processes by the order of their arrival.


Code:
#include<bits/stdc++.h>
using namespace std;
main()
{
    int wt[10],tt[10],bt[10],n,i;
    float wavg,tavg;
    printf("enter the number of process: ");
    scanf ("%d",&n);
    for(i=0;i<n;i++)
    {   printf("\nenter the burst time %d: ",i);
        scanf("%d",&bt[i]);
    }
        wt[0]=wavg=0;
        tt[0]=tavg=bt[0];
        for(i=1;i<n;i++){
        wt[i]=wt[i-1]+bt[i-1];
        tt[i]=wt[i]+bt[i];
        wavg=wavg+wt[i];
        tavg=tavg+tt[i];
}
cout<<endl<<"OUTPUT:"<<endl<<endl;

printf("process  burst  waiting  turnaround");
for(i=0;i<n;i++)
    printf("\n%d       %d        %d        %d",i,bt[i],wt[i],tt[i]);
printf("\n\n avg time: %f",wavg/n);
printf("\n turnavg time: %f",tavg/n);
cout<<endl;
}

OUTPUT:

No comments:

Post a Comment