-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (32 loc) · 1.19 KB
/
Copy pathmain.cpp
File metadata and controls
40 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <vector>
#include <memory>
#include <fstream>
#include <stdexcept>
#include "src/processService.hpp"
#include "src/processLog.hpp"
#include "src/cfs.hpp"
int main() {
try {
std::vector<std::shared_ptr<Process>> processes = getProcessFromJson("../resources/process.json");
CfsScheduler scheduler;
std::vector<std::unique_ptr<ProcessLog>> logs = scheduler.schedule(processes);
std::ofstream outFile("../process_schedule.csv");
if (!outFile.is_open()) {
throw std::runtime_error("Unable to open output file");
}
outFile << "pid,start_time,end_time" << std::endl;
for (const auto& processLog : logs) {
outFile << processLog->pid << ","
<< processLog->startTime << ","
<< processLog->endTime << std::endl;
}
outFile.close();
std::cout << "Schedule written to process_schedule.csv" << std::endl;
return 0;
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
}
// Higher-priority processes "age" slower in vruntime, so they get scheduled more frequently.