22bce7182 FCFS
22bce7182 FCFS
1. Introduction
2. Theory
FCFS Scheduling:
Key Metrics:
• Waiting Time: The total time a process spends waiting in the ready queue before it
gets executed. It is calculated as the difference between the turnaround time and
the burst time.
• Turnaround Time: The total time taken from the submission of a process to its
completion. It includes both the waiting time and the burst time of the process.
3. Algorithm
Pseudocode:
Explanation of Code:
The code implements the FCFS scheduling algorithm in Java. It calculates the waiting and
turnaround times for a given set of processes and displays the results in a tabular format.
The code is structured into three main methods:
CODE:
import java.text.ParseException;
class RAHUL_22BCE7182 {
// Method to calculate and print the average times and process details
findWaitingTime(bt, wt);
total_wt += wt[i];
total_tat += tat[i];
System.out.println(" " + (i + 1) + " " + bt[i] + " " + wt[i] + " " + tat[i]);
findavgTime(processes, burst_time);
Output:
(base) rahul_thakur@Rahuls-MacBook-Air c++ % JAVA RAHUL_22BCE7182.java
1 10 0 10
2 5 10 15
3 8 15 23
5. Results
Calculated Values:
To verify the calculations for the processes given, we’ll use the provided data:
Processes:
Waiting Time (WT) and Turnaround Time (TAT) for each process:
1. Process 1:
o Waiting Time (WT1): 0 (since it's the first process)
o Turnaround Time (TAT1): Burst Time + Waiting Time = 10 + 0 = 10
2. Process 2:
o Waiting Time (WT2): Waiting Time of Process 1 = 10 (since Process 2 starts
after Process 1 finishes)
o Turnaround Time (TAT2): Burst Time + Waiting Time = 5 + 10 = 15
3. Process 3:
o Waiting Time (WT3): Waiting Time of Process 2 + Burst Time of Process 2 =
10 + 5 = 15 (since Process 3 starts after Process 2 finishes)
o Turnaround Time (TAT3): Burst Time + Waiting Time = 8 + 15 = 23