sched file read complete

This commit is contained in:
Jai Sharma 2024-09-10 17:28:34 +05:30
parent f243104cf9
commit aee8de18b2
1 changed files with 34 additions and 3 deletions

View File

@ -3,13 +3,20 @@
#include <cstring>
#include <unistd.h>
#include <chrono>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
void fifo() {
cout << "fifo" << endl;
}
struct process_detail {
vector<int> burst_times;
};
int main(int argc, char **argv) {
if(argc != 3)
@ -22,15 +29,39 @@ int main(int argc, char **argv) {
char *file_to_search_in = argv[1];
char *scheduler_algorithm = argv[2];
vector<struct process_detail> processes_detail;
ifstream file(file_to_search_in, ios::binary);
string buffer;
while(getline(file, buffer)) {
if(buffer[0] == '<'){
continue;
}
cout << buffer << endl;
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);
}
map<string, int> temp;
temp["fifo"] = 1;
string temp1 = scheduler_algorithm;
switch(temp[temp1]){
case 1:
fifo();
break;
default:
cout << "enter fifo" << endl;
}
return 0;
}