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

FCFS Scheduling Algorithm

Usua

Uploaded by

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

FCFS Scheduling Algorithm

Usua

Uploaded by

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

FCFS Scheduling Algorithm

The algorithm for the FCFS Scheduling program in C is as follows:

1. At first, the process of execution algorithm starts


2. Then, we declare the size of an array
3. Then we get the number of processes that need to insert into the program
4. Getting the value
5. Then the first process starts with its initial position and the other processes are in a
waiting queue.
6. The total number of burst times is calculated.
7. The value is displayed
8. At last, the process stops.

Implementation code of FCFS Scheduling Algorithm


#include<stdio.h>

int main()

int n,bt[30],wait_t[30],turn_ar_t[30],av_wt_t=0,avturn_ar_t=0,i,j;

printf("Please enter the total number of processes(maximum 30):"); // the maximum process that
be used to calculate is specified.

scanf("%d",&n);

printf("\nEnter The Process Burst Timen");

for(i=0;i<n;i++) // burst time for every process will be taken as input

printf("P[%d]:",i+1);

scanf("%d",&bt[i]);

wait_t[0]=0;
for(i=1;i<n;i++)

wait_t[i]=0;

for(j=0;j<i;j++)

wait_t[i]+=bt[j];

printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time");

for(i=0;i<n;i++)

turn_ar_t[i]=bt[i]+wait_t[i];

av_wt_t+=wait_t[i];

avturn_ar_t+=turn_ar_t[i];

printf("\nP[%d]\t\t%d\t\t\t%d\t\t\t\t%d",i+1,bt[i],wait_t[i],turn_ar_t[i]);

av_wt_t/=i;

avturn_ar_t/=i; // average calculation is done here

printf("\nAverage Waiting Time:%d",av_wt_t);

printf("\nAverage Turnaround Time:%d",avturn_ar_t);

return 0;

Case-1 Input /Output


Input-: processes = P1, P2, P3

Burst time = 5, 8, 12

Output-:
Processes Burst Waiting Turn around

1 5 0 5

2 8 5 13

3 12 13 25

The Average Waiting time = 6.000000 and

The Average turn around time = 14.333333

Case-2 Input /Output


Please enter the total number of processes(maximum 30):2

Enter The Process Burst Timen

P[1]:10

P[2]:5

Process Burst Time Waiting Time Turnaround Time

P[1] 10 0 10

P[2] 5 10 15

Average Waiting Time:5

Average Turnaround Time:12

You might also like