Jelajahi Sumber

Eliminados warnings en simu.cpp (de gcc5+???)

Fabian 10 tahun lalu
induk
melakukan
2c4883fb87
1 mengubah file dengan 10 tambahan dan 7 penghapusan
  1. 10 7
      simu.cpp

+ 10 - 7
simu.cpp

@@ -38,6 +38,7 @@ static unsigned int cur_time;
 static pthread_mutex_t m_sched;
 
 enum status_t {ST_EXIT, ST_IO, ST_CPU};
+//enum status_t {ST_CPU, ST_IO, ST_EXIT};
 
 struct task_data {
 	pthread_t tid;
@@ -120,7 +121,7 @@ void simulate(SchedBase& sch, std::vector<ptsk>& lote, const Settings& settings)
 
 	//Inicializa los cpus
     contexts = vector<cpu_ctx_t>(settings.num_cores);
-    for (int i = 0; i <settings.num_cores; i++)	{
+    for (uint i = 0; i <settings.num_cores; i++)	{
         contexts[i].pid = IDLE_TASK;
         contexts[i].remaining = 0;
     }
@@ -144,7 +145,7 @@ void simulate(SchedBase& sch, std::vector<ptsk>& lote, const Settings& settings)
 		if (settings.verbose) {
 			//cerr << "--- sched, tm=" << cur_time << " pid=" << cur_pid;
 			cerr << "--- sched, tm=" << cur_time << endl;
-			for(int i = 0; i < settings.num_cores; i++) {
+			for(uint i = 0; i < settings.num_cores; i++) {
 				int pid=contexts[i].pid;
 				cerr << "cpu " << i << " pid = " << pid << " rem " << contexts[i].remaining;
 				if (pid != IDLE_TASK) { cerr << " [" << pid << " ST:"<< tsks[pid].blk << " ms:" << tsks[pid].blkms << "]"; }
@@ -170,7 +171,7 @@ void simulate(SchedBase& sch, std::vector<ptsk>& lote, const Settings& settings)
 			sch.unblock(pid); // pid
 			to_unblock.push_back(pid);
             int unblocked = 0;
-			for(int i = 0; i < settings.num_cores && !unblocked; i++) {
+			for(uint i = 0; i < settings.num_cores && !unblocked; i++) {
                 int it = contexts[i].pid;
 				if (it == pid) {
 					tsks[pid].blkms = -2;
@@ -183,7 +184,7 @@ void simulate(SchedBase& sch, std::vector<ptsk>& lote, const Settings& settings)
 			}
 		}
 		//Itera por cada cpu
-		for(int cpu= 0; cpu < settings.num_cores; cpu++){
+		for(uint cpu= 0; cpu < settings.num_cores; cpu++){
 			int cpu_pid= contexts[cpu].pid;
 			int cpu_context_remain = contexts[cpu].remaining;
 			if (!cpu_context_remain) {
@@ -233,14 +234,16 @@ void simulate(SchedBase& sch, std::vector<ptsk>& lote, const Settings& settings)
 				} else {
 					if (npid < 0 || npid >= n) { cerr << "Error!, scheduler sent an invalid pid="<<npid<< endl; return; }
 					if (!tsks[npid].running) { cerr << "Error!, scheduler sent pid="<<npid << " but that process has exited." << endl; return; }
-					if (!tsks[npid].blk == ST_IO) { cerr << "Error!, scheduler sent pid="<<npid << " but that process is still blocked." << endl; return; }
+					// FIXME! Borrar si funciona bien. ¡¡ No hay que negar un enum, no tiene sentido eso !!
+					// if (!tsks[npid].blk == ST_IO) { cerr << "Error!, scheduler sent pid="<<npid << " but that process is still blocked." << endl; return; }
+					if (tsks[npid].blk == ST_EXIT) { cerr << "Error!, scheduler sent pid="<<npid << " but that process is still blocked." << endl; return; }
 				}
                 if (cpu_pid != npid){
                     if (npid != IDLE_TASK) {
                         if (settings.switch_cost > 0) {
                             contexts[cpu].remaining += settings.switch_cost;
                         }
-                        if (cpu != tsks[npid].lastcpu && tsks[npid].lastcpu != -1) {
+                        if ((int) cpu != tsks[npid].lastcpu && tsks[npid].lastcpu != -1) {
                             contexts[cpu].remaining += settings.migrate_cost;
                         }
                         tsks[npid].lastcpu = cpu;
@@ -263,7 +266,7 @@ void simulate(SchedBase& sch, std::vector<ptsk>& lote, const Settings& settings)
 
 		//Muestra que esta realizando cada cpu
 		//y calcula si hay contexto total restante (ver while)
-		for(int i= 0; i < contexts.size(); i++){
+		for(uint i= 0; i < contexts.size(); i++){
 			context_remain += contexts[i].remaining;
 			if (contexts[i].remaining /*context_remain*/) {
 				cout << "# CONTEXT CPU " << i << " " << cur_time << endl;