|
|
@@ -17,9 +17,9 @@ SchedRR::~SchedRR() {
|
|
|
p_map.clear();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void SchedRR::load(int pid) {
|
|
|
- p_map[pid]=WAITING;
|
|
|
+ cout << "Load: " << pid << endl;
|
|
|
+ p_map[pid]=READY;
|
|
|
}
|
|
|
|
|
|
void SchedRR::unblock(int pid) {
|
|
|
@@ -27,6 +27,31 @@ void SchedRR::unblock(int pid) {
|
|
|
}
|
|
|
|
|
|
int SchedRR::next_pid(){
|
|
|
+
|
|
|
+ //Hasta el fin de la 'lista', hay alguno listo?
|
|
|
+
|
|
|
+ for( it_type it = p_map.find(cur_pid); it != p_map.end(); it++) {
|
|
|
+ if (it->first==cur_pid || it->first==IDLE_TASK) //Como arranco del sig?
|
|
|
+ continue;
|
|
|
+
|
|
|
+ cout << it->first << " => " << it->second << endl;
|
|
|
+
|
|
|
+ if (it->second == READY){
|
|
|
+ return it->first;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //Desde el inicio hasta donde estaba, hay alguno listo?
|
|
|
+ for( it_type it = p_map.begin(); it != p_map.find(cur_pid); it++) {
|
|
|
+ if (it->first==IDLE_TASK)
|
|
|
+ continue;
|
|
|
+ cout << it->first << " ==> " << it->second << endl;
|
|
|
+ if (it->second == READY)
|
|
|
+ return it->first;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (p_map[cur_pid]==READY)
|
|
|
+ return cur_pid;
|
|
|
+
|
|
|
return IDLE_TASK;
|
|
|
}
|
|
|
int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
|
@@ -38,10 +63,18 @@ int SchedRR::tick(int cpu, const enum Motivo m) {
|
|
|
p_map[cur_pid]=BLOCKED;
|
|
|
break;
|
|
|
case EXIT:
|
|
|
+ cout << "exit" << endl;
|
|
|
p_map.erase(cur_pid);
|
|
|
+
|
|
|
+ for( it_type it = p_map.begin(); it != p_map.end(); it++) {
|
|
|
+ cout << "m[" << it->first << "] = " << it->second << endl;
|
|
|
+ }
|
|
|
+
|
|
|
+ cur_pid=IDLE_TASK;
|
|
|
break;
|
|
|
}
|
|
|
cur_pid=next_pid();
|
|
|
+ cout << cur_pid << endl;
|
|
|
p_map[cur_pid]=RUNNING;
|
|
|
|
|
|
return 0;
|