0% found this document useful (0 votes)
3 views2 pages

Exp 2 Os

The document outlines an experiment for a Computer Science course at Medi-Caps University, focusing on implementing the FCFS and Shortest Job First scheduling algorithms. It includes a C++ program that calculates waiting and turnaround times for a set of processes based on user input for burst times. The program outputs the average waiting and turnaround times after processing the input data.

Uploaded by

mausam07012005
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)
3 views2 pages

Exp 2 Os

The document outlines an experiment for a Computer Science course at Medi-Caps University, focusing on implementing the FCFS and Shortest Job First scheduling algorithms. It includes a C++ program that calculates waiting and turnaround times for a set of processes based on user input for burst times. The program outputs the average waiting and turnaround times after processing the input data.

Uploaded by

mausam07012005
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
You are on page 1/ 2

Medi-Caps University

Department of Computer Science and Engineering


Operating Systems (CS3CO36)

Enrollment No: EN23CS301683 Date of Conduction: 13\02\25


Student Name: Nischaya Khadode Date of Submission: 20\02\25

Experiment No - 2
Objective :- Write a program to implement FCFS Scheduling
Algorithm and Shortest Job First Scheduling Algorithm.

Program:-
#include using namespace std;
int main()
{
int n;
cout << "Enter number of processes: ";
cin >> n;
int p[n], bt[n], wt[n], tat[n];
float total_wt = 0, total_tat = 0;
for (int i = 0; i < n; i++)
{
p[i] = i + 1;
cout << "Enter burst time for process " << i + 1 << ": ";
cin >> bt[i];
}
wt[0] = 0;
for (int i = 1; i < n; i++)
{
wt[i] = bt[i - 1] + wt[i - 1];
}
for (int i = 0; i < n; i++)
{
tat[i] = bt[i] + wt[i];
total_wt += wt[i];
total_tat += tat[i];
}
cout << "\nProcess\tBurst Time\tWaiting Time\tTurnaround Time\n";

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


{
2025/4 Semester L Jan-June 2025 2
Medi-Caps University
Department of Computer Science and Engineering
Operating Systems (CS3CO36)

Enrollment No: EN23CS301683 Date of Conduction: 13\02\25


Student Name: Nischaya Khadode Date of Submission: 20\02\25

cout << " " << p[i] << "\t" << bt[i] << "\t\t" << wt[i] << "\t\t" << tat[i]
<< "\n";
}
cout << "\nAverage Waiting Time = " << (total_wt / n) << " ms";
cout << "\nAverage Turnaround Time = " << (total_tat / n) << " ms\n";
return 0;
}
OUTPUT:-

2025/4 Semester L Jan-June 2025 3

You might also like