From aee8de18b2e7286fcab4ae6ccab45b88320d2d0a Mon Sep 17 00:00:00 2001 From: Jai Sharma <220120009> Date: Tue, 10 Sep 2024 17:28:34 +0530 Subject: [PATCH] sched file read complete --- lab3/scheduler.cpp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/lab3/scheduler.cpp b/lab3/scheduler.cpp index 124a778..6b7fc76 100644 --- a/lab3/scheduler.cpp +++ b/lab3/scheduler.cpp @@ -3,13 +3,20 @@ #include #include #include +#include +#include +#include using namespace std; void fifo() { - + cout << "fifo" << endl; } +struct process_detail { + vector 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 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 temp; + temp["fifo"] = 1; + string temp1 = scheduler_algorithm; + + + switch(temp[temp1]){ + case 1: + fifo(); + break; + default: + cout << "enter fifo" << endl; + } return 0; } \ No newline at end of file