Content-Length: 2974479 | pFad | https://www.scribd.com/document/750677950/FCFS-SJF
6FCFS & SJF
FCFS & SJF
FCFS & SJF
Program:
#include<iostream>
using namespace std;
class fcfs {
int a[10], k, b[10], c[10], d[10], n, i, j, sum, total;
float awt, atat;
public:
void getdata() {
k = total = sum = 0;
cout << "Enter the number of processes: ";
cin >> n;
b[0] = 0;
void putdata() {
cout << "Process\tBurst time\tWaiting time\tTurnaround time\n";
for(i = 0; i < n; i++) {
cout << d[i] << "\t" << a[i] << "\t\t" << b[i] << "\t\t" << c[i] << "\n";
}
cout << "Average waiting time: " << awt << "\n";
cout << "Average turnaround time: " << atat << "\n";
}
};
int main() {
fcfs obj;
obj.getdata();
obj.putdata();
return 0;
}
Output:
SJF
Program:
#include<stdio.h>
int main() {
int i, n, p[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, min, k = 1, btime = 0;
int bt[10], temp, j, at[10], wt[10], tt[10], ta = 0, sum = 0;
float wavg = 0, tavg = 0, tsum = 0, wsum = 0;
return 0;
}
Output:
------- Shortest Job First Scheduling (NP) -------
Fetched URL: https://www.scribd.com/document/750677950/FCFS-SJF
Alternative Proxies: