Fabian %!s(int64=10) %!d(string=hai) anos
pai
achega
a1dc70b31a
Modificáronse 2 ficheiros con 15 adicións e 4 borrados
  1. 12 3
      sched_rr.cpp
  2. 3 1
      sched_rr.h

+ 12 - 3
sched_rr.cpp

@@ -8,13 +8,18 @@ using namespace std;
 
 SchedRR::SchedRR(vector<int> argn) {
 	// Round robin recibe la cantidad de cores y sus cpu_quantum por parámetro
-	nucleos = argn[1];
-	quantum = argn[2];
 	cur_pid = IDLE_TASK;
+	nucleos = argn[1];
+	quantums = new uint[nucleos];
+
+	for (int i = 0; i < nucleos; i++) {
+		quantums[i] = argn[i+2];
+	}
 }
 
 SchedRR::~SchedRR() {
 	p_map.clear();
+	delete [] quantums;
 }
 
 void SchedRR::load(int pid) {
@@ -53,6 +58,10 @@ int SchedRR::next_pid() {
 int SchedRR::tick(int cpu, const enum Motivo m) {
 	uint switch_process=0;
 
+	for (int i == 0; i<nucleos; i++) {
+		uint current = current_pid(
+	}
+
 	switch(m) {
 		case TICK:
 			p_map[cur_pid].quantum_count++;
@@ -71,7 +80,7 @@ int SchedRR::tick(int cpu, const enum Motivo m) {
 	if (cur_pid==IDLE_TASK)
 		switch_process=1;
 
-	if (p_map[cur_pid].quantum_count>=quantum) {
+	if (p_map[cur_pid].quantum_count>=quantums[cpu]) {
 		switch_process=1;
 		p_map[cur_pid].state=READY;
 		p_map[cur_pid].quantum_count=0;

+ 3 - 1
sched_rr.h

@@ -17,9 +17,10 @@ class SchedRR : public SchedBase {
 		virtual void unblock(int pid);
 		virtual int tick(int cpu, const enum Motivo m);	
 		virtual int next_pid();
+		virtual int next_free_cpu();
 	private:
 		uint nucleos;
-		uint quantum;
+		uint* quantums;
 		int cur_pid;
 		
 		enum state { READY, BLOCKED, RUNNING };
@@ -33,6 +34,7 @@ class SchedRR : public SchedBase {
 		std::map<int, process> p_map;
 		typedef std::map<int,process>::iterator it_type;
 
+
 /* llenar */
 };