2024-09-03 17:11:02 +05:30
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <cstring>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <chrono>
|
2024-09-10 17:28:34 +05:30
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
#include <bits/stdc++.h>
|
2024-09-03 17:11:02 +05:30
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
void fifo() {
|
2024-09-10 17:28:34 +05:30
|
|
|
cout << "fifo" << endl;
|
2024-09-03 17:11:02 +05:30
|
|
|
}
|
|
|
|
|
2024-09-10 17:28:34 +05:30
|
|
|
struct process_detail {
|
|
|
|
vector<int> burst_times;
|
|
|
|
};
|
|
|
|
|
2024-09-03 17:11:02 +05:30
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
if(argc != 3)
|
|
|
|
{
|
|
|
|
cout <<"usage: ./scheduler.out <path-to-workload-file> <scheduler_algorithm>\nprovided arguments:\n";
|
|
|
|
for(int i = 0; i < argc; i++)
|
|
|
|
cout << argv[i] << "\n";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *file_to_search_in = argv[1];
|
|
|
|
char *scheduler_algorithm = argv[2];
|
2024-09-10 17:28:34 +05:30
|
|
|
|
|
|
|
vector<struct process_detail> processes_detail;
|
2024-09-03 17:11:02 +05:30
|
|
|
ifstream file(file_to_search_in, ios::binary);
|
|
|
|
string buffer;
|
2024-09-10 17:28:34 +05:30
|
|
|
|
|
|
|
|
2024-09-03 17:11:02 +05:30
|
|
|
while(getline(file, buffer)) {
|
2024-09-10 16:23:13 +05:30
|
|
|
if(buffer[0] == '<'){
|
|
|
|
continue;
|
|
|
|
}
|
2024-09-10 17:28:34 +05:30
|
|
|
istringstream iss(buffer);
|
|
|
|
string word;
|
|
|
|
struct process_detail pd;
|
|
|
|
memset(&pd,0,sizeof(struct process_detail));
|
|
|
|
|
|
|
|
while(iss>>word){
|
|
|
|
pd.burst_times.push_back(stoi(word));
|
|
|
|
cout << stoi(word) << endl;
|
|
|
|
}
|
|
|
|
processes_detail.push_back(pd);
|
2024-09-03 17:11:02 +05:30
|
|
|
}
|
|
|
|
|
2024-09-10 17:28:34 +05:30
|
|
|
map<string, int> temp;
|
|
|
|
temp["fifo"] = 1;
|
|
|
|
string temp1 = scheduler_algorithm;
|
|
|
|
|
|
|
|
|
|
|
|
switch(temp[temp1]){
|
|
|
|
case 1:
|
|
|
|
fifo();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cout << "enter fifo" << endl;
|
|
|
|
}
|
2024-09-03 17:11:02 +05:30
|
|
|
return 0;
|
|
|
|
}
|