0% found this document useful (0 votes)
17 views1 page

FCFS CPU Scheduling

The document contains a C program that simulates the First Come First Serve (FCFS) CPU scheduling algorithm. It prompts the user to enter the number of processes and their respective burst times, then calculates and displays the waiting time and turnaround time for each process. Finally, it computes and prints the average waiting time and average turnaround time.

Uploaded by

Sachin Samriddh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

FCFS CPU Scheduling

The document contains a C program that simulates the First Come First Serve (FCFS) CPU scheduling algorithm. It prompts the user to enter the number of processes and their respective burst times, then calculates and displays the waiting time and turnaround time for each process. Finally, it computes and prints the average waiting time and average turnaround time.

Uploaded by

Sachin Samriddh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Write a program to simulate the FCFS CPU scheduling algorithm.

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum,wt,tat,twt,ttat;
int t[10];
float awt,atat;
clrscr();
printf("Enter number of processors:\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n Enter the Burst Time of the process %d",i+1);
scanf("\n %d",&t[i]);
}
printf("\n\n FIRST COME FIRST SERVE SCHEDULING ALGORITHM \n");
printf("\n Process ID \t Waiting Time \t Turn Around Time \n");
printf("1 \t\t 0 \t\t %d \n",t[0]);
sum=0;
twt=0;
ttat=t[0];
for(i=1;i<n;i++)
{
sum+=t[i-1];
wt=sum;
tat=sum+t[i];
twt=twt+wt;
ttat=ttat+tat;
printf("\n %d \t\t %d \t\t %d",i+1,wt,tat);
printf("\n\n");
}
awt=(float)twt/n;
atat=(float)ttat/n;
printf("\n Average Waiting Time %4.2f",awt);
printf("\n Average Turnaround Time %4.2f",atat);
getch();
}

You might also like