| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include <map>
- #include <queue>
- #include "sched_rr.h"
- #include "basesched.h"
- #include <iostream>
- using namespace std;
- SchedRR::SchedRR(vector<int> argn) {
- // 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() {
- p_map.clear();
- }
- void SchedRR::load(int pid) {
- p_map[pid]=WAITING;
- }
- void SchedRR::unblock(int pid) {
- p_map[pid]=READY;
- }
- int SchedRR::next_pid(){
- return IDLE_TASK;
- }
- int SchedRR::tick(int cpu, const enum Motivo m) {
- 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;
- }
|