0% found this document useful (0 votes)
3 views2 pages

OS EXP5 (1)

The document contains a C program that implements the First-Come, First-Served (FCFS) CPU scheduling algorithm. It calculates the waiting time and turnaround time for a given number of processes based on their burst times. The program also computes and displays the average waiting and turnaround times after processing the input data.

Uploaded by

vajey10381
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)
3 views2 pages

OS EXP5 (1)

The document contains a C program that implements the First-Come, First-Served (FCFS) CPU scheduling algorithm. It calculates the waiting time and turnaround time for a given number of processes based on their burst times. The program also computes and displays the average waiting and turnaround times after processing the input data.

Uploaded by

vajey10381
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/ 2

Name: Vishwakarma Chandan Year/Branch: SE/CMPN

Batch:C1 RollNo:33
Experiment No: 5
Program:
#include <stdio.h>
int main()
{
int n, bt[20], wt[20], tat[20], i, j;
float avwt = 0, avtat = 0;
printf("Enter total number of processes (maximum 20): ");
scanf("%d", &n);
printf("\nEnter Process Burst Time\n");
for (i = 0; i < n; i++)
{
printf("P[%d]: ", i + 1);
scanf("%d", &bt[i]);
}
wt[0] = 0;
for (i = 1; i < n; i++)
{
wt[i] = 0;
for (j = 0; j < i; j++)
wt[i] += bt[j];
}
printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time\n");
for (i = 0; i < n; i++)
{
tat[i] = bt[i] + wt[i];
avwt += wt[i];
avtat += tat[i];
printf("\nP[%d]\t\t%d\t\t%d\t\t%d", i + 1, bt[i], wt[i], tat[i]);
}
avwt /= i;
avtat /= i;
printf("\n\nAverage Waiting Time: %f", avwt);
printf("\nAverage Turnaround Time: %f", avtat);
return 0;
}

Output:

Conclusion:
Thus we implemented FCFS CPU scheduling algorithm in C.

You might also like