spz3/Process.cpp

22 lines
764 B
C++

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