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

FCFS Scheduling Code Explained

The document explains a C program that implements First-Come, First-Served (FCFS) scheduling for process management. It details the declaration of variables for burst times, waiting times, and turnaround times, as well as the calculation of these times and their averages. The program takes user input for burst times and outputs a table of results along with average waiting and turnaround times.
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)
9 views1 page

FCFS Scheduling Code Explained

The document explains a C program that implements First-Come, First-Served (FCFS) scheduling for process management. It details the declaration of variables for burst times, waiting times, and turnaround times, as well as the calculation of these times and their averages. The program takes user input for burst times and outputs a table of results along with average waiting and turnaround times.
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

FCFS Scheduling - Code Explanation

#include <stdio.h>

Includes the standard input/output library. Needed to use printf and scanf.

void main() {

Main function of the program. We use void main() in Turbo C.

int n, i; int bt[20], wt[20], tat[20]; float avg_wt = 0, avg_tat = 0;

Declares variables:

- n: number of processes

- bt: burst times

- wt: waiting times

- tat: turnaround times

- avg_wt and avg_tat to store totals for average calculation.

Input for burst times

Takes burst time for each process using a loop. Uses scanf to read user input.

wt[0] = 0;

Waiting time for the first process is always zero in FCFS scheduling.

Calculating waiting time

Each process's waiting time = previous waiting time + previous burst time.

Calculating turnaround time and averages

Turnaround time = burst time + waiting time. We also calculate the total waiting and turnaround times to

compute averages.

Printing the result

Prints a table showing each processs Burst Time, Waiting Time, and Turnaround Time.

Printing averages

Displays the average waiting and turnaround times at the end.

You might also like