Exp. No. 1 - FCFS
Exp. No. 1 - FCFS
CPU SCHEDULINGALGORITHMS
AIM: To write a C program to simulate the CPU scheduling algorithm First Come First
Serve (FCFS)
DESCRIPTION:
To calculate the average waiting time using the FCFS algorithm first the waiting time of the first
process is kept zero and the waiting time of the second process is the burst time of the first process
and the waiting time of the third process is the sum of the burst times of the first and the second
process and so on. After calculating all the waiting times the average waiting time is calculated as
the average of all the waiting times. FCFS mainly says first come first serve the algorithm which
came first will be served first.
ALGORITHM:
#include <stdio.h>
int main() {
int bt[20], wt[20], tat[20], n;
float wtavg = 0, tatavg = 0;
wt[0] = 0;
tat[0] = bt[0];
return 0;
}
INPUT
Enter the number of processes -- 3
Enter Burst Time for Process 0 -- 24
Enter Burst Time for Process 1 -- 3
Enter Burst Time for Process 2 -- 3
OUTPUT
PROCESS BURST TIME WAITING TIME TURNAROUND
TIME
P0 24 0 24
P1 3 24 27
P2 3 27 30
Average Waiting Time-- 17.000000
Average Turnaround Time -- 27.000000