spz3/Process.cpp

20 lines
731 B
C++

#include "Process.h"
#include <random>
#include <utility>
Process::Process(const unsigned int id, std::vector<PTE> page_table, const unsigned int working_set_size,
const unsigned int execution_time) : page_table(std::move(page_table)), execution_time(execution_time), elapsed_time(0),
id(id), next(nullptr), prev(nullptr) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<unsigned int> page_table_distribution(0, this->page_table.size() - 1);
for (int i = 0; i < working_set_size; ++i) {
working_set.push_back(page_table_distribution(gen));
}
}
bool Process::is_finished() const {
return elapsed_time >= execution_time;
}