Browse Source

firstTick ?

David 10 years atrás
parent
commit
0fa9b6957e
2 changed files with 8 additions and 2 deletions
  1. 7 2
      sched_sjf.cpp
  2. 1 0
      sched_sjf.h

+ 7 - 2
sched_sjf.cpp

@@ -8,13 +8,13 @@ using namespace std;
 SchedSJF::SchedSJF(vector<int> argn) {
     // Recibe la cantidad de cores 
     cout << "Constructor SchedSJF \n";
-    cout << "Test \n" ;
     nucleos = argn[1];
+	firstTick=true;
 
     for (uint i = 2; i < argn.size(); i++) {
         // Cargamos los procesos con un id y una duration
         uint duration = argn[i];
-        cout << "Loadinggg " << i-2 << " " << duration << "\n";
+        //cout << "Loadinggg " << i-2 << " " << duration << "\n";
         p_map[i - 2].duration = duration; 
 	}
 }
@@ -38,6 +38,11 @@ void SchedSJF::unblock(int pid) {
 int SchedSJF::tick(int cpu, const enum Motivo m) {
     /* motivo TICK / BLOCK / EXIT / IDLE_TASK */
     uint cur_pid = current_pid(cpu);
+	if (firstTick){ //FIXME
+		cur_pid=0;
+		firstTick=false;
+	}
+
     cout << "Inicio tick: cpu " << cpu << " motivo " << m << " curr_pid " << cur_pid << "\n";
     if (m == TICK) {
         return cur_pid;  // El proceso esta corriendo

+ 1 - 0
sched_sjf.h

@@ -30,6 +30,7 @@ class SchedSJF : public SchedBase {
 			}	
 		};
 
+		bool firstTick;
 		std::map<int, Process> p_map;  // Mapeo de los procesos
 		typedef std::map<int,Process>::iterator it_type;