Fabian 10 éve
szülő
commit
83269d1fc6
2 módosított fájl, 20 hozzáadás és 11 törlés
  1. 14 8
      Makefile
  2. 6 3
      sched_rr.cpp

+ 14 - 8
Makefile

@@ -22,25 +22,31 @@ tasks.o: tasks.cpp tasks.h basetask.h
 
 clean:
 	rm -f $(OBJS) $(MAIN)
-	rm -f *.png
+	rm -rf informe/imagenes
+	rm -rf informe/*.pdf
+
 informe/informe.pdf: informe/informe.md
 
 informe: informe/informe.pdf
 	pandoc informe/informe.md -o informe/informe.pdf
+
 new: clean all
 
-ejercicio1: all
+makedir:
+	mkdir -p informe/imagenes
+
+ejercicio1: all makedir
 	./simusched consola.tsk 1 1 2 SchedFCFS | ./graphsched.py > informe/imagenes/ejercicio1.png
 
-ejercicio2: all
+ejercicio2: all makedir
 	./simusched ejer2.tsk 1 2 99 SchedFCFS | ./graphsched.py > informe/imagenes/ejercicio2_1core.png
 	./simusched ejer2.tsk 2 2 99 SchedFCFS | ./graphsched.py > informe/imagenes/ejercicio2_2core.png
 	./simusched ejer2.tsk 4 2 99 SchedFCFS | ./graphsched.py > informe/imagenes/ejercicio2_4core.png
 
-ejercicio3: all
+ejercicio3: all makedir
 	./simusched ejer3.tsk 1 2 99 SchedFCFS | ./graphsched.py > informe/imagenes/ejercicio3_1core.png
 
-ejercicio4: all
-	./simusched ejer2.tsk 1 2 99 SchedRR 1 02 | ./graphsched.py > informe/imagenes/ejercicio4_1core_02q.png
-	./simusched ejer2.tsk 1 2 99 SchedRR 1 05 | ./graphsched.py > informe/imagenes/ejercicio4_1core_05q.png
-	./simusched ejer2.tsk 1 2 99 SchedRR 1 10 | ./graphsched.py > informe/imagenes/ejercicio4_1core_10q.png
+ejercicio5: all makedir
+	./simusched ejer2.tsk 1 2 99 SchedRR 1 02 | ./graphsched.py > informe/imagenes/ejercicio5_1core_02q.png
+	./simusched ejer2.tsk 1 2 99 SchedRR 1 05 | ./graphsched.py > informe/imagenes/ejercicio5_1core_05q.png
+	./simusched ejer2.tsk 1 2 99 SchedRR 1 10 | ./graphsched.py > informe/imagenes/ejercicio5_1core_10q.png

+ 6 - 3
sched_rr.cpp

@@ -27,8 +27,8 @@ void SchedRR::unblock(int pid) {
 
 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?
 			continue;
@@ -37,6 +37,7 @@ int SchedRR::next_pid(){
 			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) 
@@ -66,18 +67,20 @@ int SchedRR::tick(int cpu, const enum Motivo m) {
 			cur_pid=IDLE_TASK;
 			break;
 	}
+
 	if (cur_pid==IDLE_TASK)
 		switch_process=1;
+
 	if (p_map[cur_pid].quantum_count>quantum) {
 		switch_process=1;
 		p_map[cur_pid].state=READY;
 		p_map[cur_pid].quantum_count=0;
 	}
-	if (switch_process){
+
+	if (switch_process) {
 		cur_pid=next_pid();
 		p_map[cur_pid].state=RUNNING;
 	}
 	
-	
 	return cur_pid;
 }