|
@@ -25,34 +25,34 @@ void SchedRR::unblock(int pid) {
|
|
|
p_map[pid].state=READY;
|
|
p_map[pid].state=READY;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int SchedRR::next_pid(){
|
|
|
|
|
-
|
|
|
|
|
- // FIXME Usar colas?
|
|
|
|
|
- //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?
|
|
|
|
|
|
|
+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 == IDLE_TASK)
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
- if (it->second.state == READY){
|
|
|
|
|
|
|
+ if (it->second.state == READY)
|
|
|
return it->first;
|
|
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)
|
|
|
|
|
|
|
+ // 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;
|
|
continue;
|
|
|
|
|
+
|
|
|
if (it->second.state == READY)
|
|
if (it->second.state == READY)
|
|
|
return it->first;
|
|
return it->first;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (p_map[cur_pid].state==READY)
|
|
|
|
|
|
|
+ if (p_map[cur_pid].state == READY)
|
|
|
return cur_pid;
|
|
return cur_pid;
|
|
|
|
|
|
|
|
return IDLE_TASK;
|
|
return IDLE_TASK;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
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;
|
|
|
|
|
+
|
|
|
switch(m) {
|
|
switch(m) {
|
|
|
case TICK:
|
|
case TICK:
|
|
|
p_map[cur_pid].quantum_count++;
|
|
p_map[cur_pid].quantum_count++;
|
|
@@ -71,7 +71,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>=quantum) {
|
|
|
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;
|