0% found this document useful (0 votes)
59 views

Experiment-3: AIM: To Implement The FCFS Algorithm

The document describes an experiment to implement the First Come First Serve (FCFS) scheduling algorithm. It takes the burst times of 3 processes as input, calculates their waiting times, turnaround times, and average waiting and turnaround times. The key steps are: 1) it takes the burst times of 3 processes as input, 2) calculates the waiting time of each process based on the burst times of the previous processes, 3) calculates the completion time, turnaround time and waiting time of each process, 4) calculates the average waiting time and average turnaround time.

Uploaded by

Kartikey Arora
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Experiment-3: AIM: To Implement The FCFS Algorithm

The document describes an experiment to implement the First Come First Serve (FCFS) scheduling algorithm. It takes the burst times of 3 processes as input, calculates their waiting times, turnaround times, and average waiting and turnaround times. The key steps are: 1) it takes the burst times of 3 processes as input, 2) calculates the waiting time of each process based on the burst times of the previous processes, 3) calculates the completion time, turnaround time and waiting time of each process, 4) calculates the average waiting time and average turnaround time.

Uploaded by

Kartikey Arora
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

EXPERIMENT-3

AIM: To implement the FCFS algorithm.


#include <stdio.h>
#include <conio.h>
void main()
{
int bt[3];
int awt = 0;
int wt[3]; int ct[3], tat[3];
int i, sum=0, sum1 = 0;
int atat;
clrscr();
printf("\nEnter the burst time for the processes
(3)");
for(i=0; i<3; i++)
{
printf("\nBurst time for process %d\t", i+1);
scanf("%d", &bt[i]);
}
wt[0] = 0;
for(i = 1; i <3; i++)
{
//sum1 = bt[i-1] + bt[i];
//printf("%d", sum1);
wt[i] = bt[i-1] + bt[i-2];
printf("%d ", wt[i]);
}
for(i=0; i<3; i++)
{
ct[i] = wt[i] + bt[i];
}
//printf("%d", ct[2]);
//printf("%d", wt[2]);
for(i=0; i<3; i++)
{

tat[i] = bt[i] + wt[i];


}

//printf("%d", wt[1]);
for(i=0; i<3; i++)
{
sum += wt[i];
}
//printf("%d", awt);
awt = sum/3;
printf("\nAverage waiting time for the given set is
%d", awt);
printf("\nTurn around time are :%d %d %d", tat[0],
tat[1], tat[2]);
printf("\nWaiting time are :%d %d %d", wt[0], wt[1],
wt[2]);
atat= (tat[0] + tat[1] + tat[2]) /3;
printf("\nAverage turn around time : %d", atat);
getch();
}

Output:

You might also like