Ritikos1 Merged (1)
Ritikos1 Merged (1)
EXPERIMENT – 03
Conclusion
You have successfully installed Linux on your computer.
Remember to:
- Update your system
- Install any required software
Enjoy your new Linux experience!
Note: Installation steps may slightly vary depending on the specific Linux
distribution. It is always best to refer to official documentation or user guides
provided by the Linux distribution for detailed instructions.
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch B1
Date of Experiment: Date of Submission Submitted on:
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
SOURCE CODE:
#include <stdio.h>
struct process {
int burst; // Total burst time
int wait; // Waiting time
int comp; // Completed time (how much CPU time given)
int f; // Flag to check if process is done (1 = not done, 0 = done)
} p[20];
int main() {
int n, i, j;
int totalwait = 0, totalturn = 0;
int quantum;
int flag = 1;
int time = 0;
return 0;
}
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch B1
Date of Experiment: Date of Submission Submitted on:
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
OUTPUT:
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch: B-01
Date of Experiment:23/05/25 Date of Submission Submitted on:
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
SOURCECODE:
#include<stdio.h>
intmain(){
inti,j,n,temp;
intpno[10],bt[10],wt[10],tt[10]; float
sum = 0, at = 0;
printf("Enterthenumberofprocesses:"); scanf("%d",
&n);
//Inputbursttimesandinitializeprocessnumbers
printf("Enter the burst time of each process:\n");
for (i = 0; i < n; i++) {
printf("P%d:", i);
scanf("%d",&bt[i]);
pno[i]=i;//Initializeprocessnumber
}
//Sortbybursttime(SJF)
for(i=0;i< n-1;i++){
for(j=i+1;j<n;j++){ if
(bt[i] > bt[j]) {
//Swapbursttimes
temp = bt[i];
bt[i] = bt[j];
bt[j]=temp;
//Swapprocessnumbers temp
= pno[i];
pno[i]=pno[j];
pno[j] = temp;
}
}
}
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch: B-01
Date of Experiment:23/05/25 Date of Submission Submitted on:
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
//Calculatewaitingtime
wt[0] = 0;
for(i=1;i<n;i++){
wt[i]=wt[i-1]+bt[i-1]; sum +=
wt[i];
}
//Calculateturnaroundtimeandtotalturnaroundtime
printf("\nProcessNo.\tBurstTime\tWaitingTime\tTurnaroundTime\n"); for
(i = 0; i < n; i++) {
tt[i]=bt[i]+wt[i]; at
+= tt[i];
printf("P%d\t\t%d\t\t%d\t\t%d\n",pno[i],bt[i],wt[i],tt[i]);
}
return0;
}
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch: B-01
Date of Experiment:23/05/25 Date of Submission Submitted on:
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
OUTPUT:
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch: B-01
Date of Experiment: 23/05/25 Date of Submission Submitted on: 30/05/25
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
SOURCECODE:
#include <iostream>
#include <vector>
using namespace std;
struct Process {
int process_id;
int arrival_time;
int burst_time;
int start_time;
int completion_time;
int turnaround_time;
int waiting_time;
double avg_turnaround_time = 0;
double avg_waiting_time = 0;
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch: B-01
Date of Experiment: 23/05/25 Date of Submission Submitted on: 30/05/25
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
avg_turnaround_time /= process_list.size();
avg_waiting_time /= process_list.size();
cout << "Average Turnaround Time: " << avg_turnaround_time << endl;
cout << "Average Waiting Time: " << avg_waiting_time << endl;
}
int main() {
vector<Process> processes = {
Process(1, 0, 5),
Process(2, 1, 3),
Process(3, 2, 8),
Process(4, 3, 6),
Process(5, 4, 2)
};
fcfs_scheduling(processes);
return 0;
}
Name of Student: Ritik Yadav Class: B.Tech
Enrollment No: 0827CS231221 Batch: B-01
Date of Experiment: 23/05/25 Date of Submission Submitted on: 30/05/25
Remarks by faculty: Grade:
Signature of student: Signature of Faculty:
OUTPUT: