#include <stdio.
h>
#include <conio.h>
int main() {
int n, i;
int bt[20], wt[20], tat[20];
int total_wt = 0, total_tat = 0;
clrscr();
printf("Enter the number of processes: ");
scanf("%d", &n);
printf("Enter burst time for each process:\n");
for (i = 0; i < n; i++) {
printf("Process %d: ", i + 1);
scanf("%d", &bt[i]);
wt[0] = 0;
for (i = 1; i < n; i++) {
wt[i] = bt[i - 1] + wt[i - 1];
for (i = 0; i < n; i++) {
tat[i] = bt[i] + wt[i];
total_wt += wt[i];
total_tat += tat[i];
printf("\nProcess\tBurst Time\tWaiting Time\tTurnaround Time\n");
for (i = 0; i < n; i++) {
printf("%d\t%d\t\t%d\t\t%d\n", i + 1, bt[i], wt[i], tat[i]);
printf("\nAverage waiting time = %.2f", (float)total_wt / n);
printf("\nAverage turnaround time = %.2f", (float)total_tat / n);
getch();
return 0;
First-Come, First-Served (FCFS) Scheduling Algorithm
First-Come, First-Served (FCFS) is one of the simplest CPU scheduling algorithms used in operating
systems. It operates in the same manner as a queue: the process that arrives first is executed first.
It is a non-preemptive scheduling algorithm, meaning once a process starts execution, it cannot be
interrupted until it finishes.
Advantages:
1. Simple and Easy to Implement: The logic is straightforward and requires minimal system
resources.
2. Fair: Each process is treated equally based on its arrival time.
3. Predictable: Easy to calculate waiting and turnaround times.
How FCFS Works:
1. Maintain a queue of processes.
2. The process at the front of the queue is assigned the CPU first.
3. Once the process finishes execution, the CPU is assigned to the next process in the queue.
4. Repeat until all processes are executed.
Key Features of FCFS:
1. Non-preemptive: Processes are executed to completion without interruption.