UNIX C Program for First Come First Serve Scheduling Algorithm | CS1254-Operating Systems Lab


AIM:
To write a LINUX/UNIX C Program for the Implementation of First Come First Serve Scheduling Algorithm in CS1254 - Operating Systems Laboratory.

SOURCE CODE:
#include<stdio.h>
main()
{
int n,a[10],b[10],t[10],w[10],g[10],i,m;
float att=0,awt=0;
for(i=0;i<0;i++)
{
a[i]=0;b[i]=0;w[i]=0;g[i]=0;
}
printf(“Enter the number of processes:”);
scanf(“%d”,&n);
printf(“Enter the burst time:”);
for(i=0;i<n;i++)
scanf(“%d”,&b[i]);
printf(“Enter the arrival time:”);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
g[0]=0;
for(i=0;i<10;i++)
{
w[i]=g[i]-a[i];
t[i]=g[i+1]-a[i];
awt=awt+w[i]
att=att+t[i];
}
awt=awt/n;
att=att/n;
printf(“\n\t Process\t Waiting time \t Turnaround time\n”);
for(i=0;i<n;i++)
{
printf(“\t %d\t\t  %d\t\\t  %d\n”I,w[i],t[i]);
}
printf(“\n The average waiting time is %t \n”,awt);
printf(“The average turnaround time is %f\n”,att);

OUTPUT:
[examuser35@localhost Jebastin]$ cc fcfs.c
[examuser35@localhost Jebastin]$ ./a.out
Enter the number of processes:3
Enter the burst time:1
2
3
Enter the arrival time:0
1
2

Process        Waiting time         Turnaround time
    1                                        
    1                      3                             2
    2                      6                             4

The average waiting time is 3.3333
The average turnaround time is 2.333
Previous
Next Post »

Still not found what you are looking for? Try again here.