|
@@ -8,13 +8,18 @@ using namespace std;
|
|
|
|
|
|
|
|
SchedRR::SchedRR(vector<int> argn) {
|
|
SchedRR::SchedRR(vector<int> argn) {
|
|
|
// Round robin recibe la cantidad de cores y sus cpu_quantum por parámetro
|
|
// Round robin recibe la cantidad de cores y sus cpu_quantum por parámetro
|
|
|
- nucleos = argn[1];
|
|
|
|
|
- quantum = argn[2];
|
|
|
|
|
cur_pid = IDLE_TASK;
|
|
cur_pid = IDLE_TASK;
|
|
|
|
|
+ nucleos = argn[1];
|
|
|
|
|
+ quantums = new uint[nucleos];
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < nucleos; i++) {
|
|
|
|
|
+ quantums[i] = argn[i+2];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SchedRR::~SchedRR() {
|
|
SchedRR::~SchedRR() {
|
|
|
p_map.clear();
|
|
p_map.clear();
|
|
|
|
|
+ delete [] quantums;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void SchedRR::load(int pid) {
|
|
void SchedRR::load(int pid) {
|
|
@@ -53,6 +58,10 @@ int SchedRR::next_pid() {
|
|
|
int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
|
uint switch_process=0;
|
|
uint switch_process=0;
|
|
|
|
|
|
|
|
|
|
+ for (int i == 0; i<nucleos; i++) {
|
|
|
|
|
+ uint current = current_pid(
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
switch(m) {
|
|
switch(m) {
|
|
|
case TICK:
|
|
case TICK:
|
|
|
p_map[cur_pid].quantum_count++;
|
|
p_map[cur_pid].quantum_count++;
|
|
@@ -71,7 +80,7 @@ int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
|
if (cur_pid==IDLE_TASK)
|
|
if (cur_pid==IDLE_TASK)
|
|
|
switch_process=1;
|
|
switch_process=1;
|
|
|
|
|
|
|
|
- if (p_map[cur_pid].quantum_count>=quantum) {
|
|
|
|
|
|
|
+ if (p_map[cur_pid].quantum_count>=quantums[cpu]) {
|
|
|
switch_process=1;
|
|
switch_process=1;
|
|
|
p_map[cur_pid].state=READY;
|
|
p_map[cur_pid].state=READY;
|
|
|
p_map[cur_pid].quantum_count=0;
|
|
p_map[cur_pid].quantum_count=0;
|