|
@@ -1,4 +1,4 @@
|
|
|
-#include <vector>
|
|
|
|
|
|
|
+#include <map>
|
|
|
#include <queue>
|
|
#include <queue>
|
|
|
#include "sched_rr.h"
|
|
#include "sched_rr.h"
|
|
|
#include "basesched.h"
|
|
#include "basesched.h"
|
|
@@ -8,22 +8,41 @@ 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[0];
|
|
|
|
|
+ quantum = argn[1];
|
|
|
|
|
+ cur_pid = IDLE_TASK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SchedRR::~SchedRR() {
|
|
SchedRR::~SchedRR() {
|
|
|
-/* completar */
|
|
|
|
|
|
|
+ p_map.clear();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
void SchedRR::load(int pid) {
|
|
void SchedRR::load(int pid) {
|
|
|
-/* completar */
|
|
|
|
|
|
|
+ p_map[pid]=WAITING;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void SchedRR::unblock(int pid) {
|
|
void SchedRR::unblock(int pid) {
|
|
|
-/* completar */
|
|
|
|
|
|
|
+ p_map[pid]=READY;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+int SchedRR::next_pid(){
|
|
|
|
|
+ return IDLE_TASK;
|
|
|
|
|
+}
|
|
|
int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
|
-/* completar */
|
|
|
|
|
|
|
+ switch(m) {
|
|
|
|
|
+ case TICK:
|
|
|
|
|
+ p_map[cur_pid]=READY;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case BLOCK:
|
|
|
|
|
+ p_map[cur_pid]=BLOCKED;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EXIT:
|
|
|
|
|
+ p_map.erase(cur_pid);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ cur_pid=next_pid();
|
|
|
|
|
+ p_map[cur_pid]=RUNNING;
|
|
|
|
|
+
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|