apuntelebien

RMAG news
node *t = r;
while(t -> next() != nullptr && t -> next() -> prty() == r -> prty()){
t = t -> next();
}
r -> next(t -> next());
t -> next(r);

cout << “t”<< r -> id() << ” no terminadott”<< r -> tme()<< “tt”<< r -> prty()<< “tt”<< tR<< “tt”;

node *x = r -> next();
while (x != nullptr) {

std::cout << ” | ” << x -> id() << ” ” << x -> tme() << ” ” << x -> prty() << ” | “;
x = x -> next();
}

cout << endl;

void process::Prioridad() {
//se ordena por prioridad
node *p = head;
while (p != nullptr) {
node *q = p -> next();
while (q != nullptr) {

if (q -> prty() > p -> prty()) {

char idx = p -> id();
int tmex = p -> tme();
int prtyx = p -> prty();

p -> setid(q -> id());
p -> settme(q -> tme());
p -> setprty(q -> prty());

q -> setid(idx);
q -> settme(tmex);
q -> setprty(prtyx);

}
q = q -> next();
}
p = p -> next();
}

node *r = head;
float tR = 0, tRT = 0;
int Q = calcQ();
cout << “ntId //” << ” Tiempo de ejecucion //” << ” Prioridad //” << ” Tiempo de retorno //” << ” Procesos restantes (ID Tiempo Prioridad)” << endl;

while (r != nullptr) {

if (r -> tme() <= Q) {

tR += r -> tme();
tRT += tR;
cout << “t”<< r -> id() << “tt”<< r -> tme()<< “tt”<< r -> prty()<< “tt”<< tR<< “tt”;
node *t = r -> next();
while(t != nullptr){
std::cout << ” | ” << t -> id() << ” ” << t -> tme() << ” ” << t -> prty() << ” | “;
t = t -> next();
}
cout << endl;
r = r -> next();
}else{

tR += Q;
r -> settme(r -> tme() – Q);
r -> setprty(r -> prty() – 1);
cout << “t”<< r -> id() << ” pendiente “<< r -> tme()<< “tt”<< r -> prty()<< “tt”<< tR<< “tt”;
node *t = r;
while(t != nullptr){
std::cout << ” | ” << t -> id() << ” ” << t -> tme() << ” ” << t -> prty() << ” | “;
t = t -> next();
}
cout << endl;
/*
node *t = r;
while(t -> next() != nullptr && t -> next() -> prty() == r -> prty()){
t = t -> next();
}
r -> next(t -> next());
t -> next(r);

cout << “t”<< r -> id() << ” no terminadott”<< r -> tme()<< “tt”<< r -> prty()<< “tt”<< tR<< “tt”;

node *x = r -> next();
while (x != nullptr) {

std::cout << ” | ” << x -> id() << ” ” << x -> tme() << ” ” << x -> prty() << ” | “;
x = x -> next();
}

cout << endl;
*/
}

}

cout << “ntTiempo promedio: “<< (float)tRT/n<< endl;
cout << “ntQuantum: “<< Q<< endl;

}

node *r = head;
float tR = 0, tRT = 0;
int Q = calcQ();
cout << “ntId //” << ” Tiempo de ejecucion //” << ” Prioridad //” << ” Tiempo de retorno //” << ” Procesos restantes (ID Tiempo Prioridad)” << endl;

while (r != nullptr) {
if (r->tme() <= Q) {
tR += r->tme();
tRT += tR;
cout << “t” << r->id() << “tt” << r->tme() << “tt” << r->prty() << “tt” << tR << “tt”;
node *t = r->next();
while (t != nullptr) {
std::cout << ” | ” << t->id() << ” ” << t->tme() << ” ” << t->prty() << ” | “;
t = t->next();
}
cout << endl;
r = r->next();
} else {
tR += Q;
r->settme(r->tme() – Q);
r->setprty(r->prty() – 1);
cout << “t” << r->id() << ” pendiente ” << r->tme() << “tt” << r->prty() << “tt” << tR << “tt”;
node *t = r;
while (t != nullptr) {
std::cout << ” | ” << t->id() << ” ” << t->tme() << ” ” << t->prty() << ” | “;
t = t->next();
}
cout << endl;

// Aquí vamos a reordenar la lista si es necesario
node *t2 = r;
while (t2->next() != nullptr && t2->next()->prty() > r->prty()) {
t2 = t2->next();
}
if (t2 != r) {
node *temp = r->next();
r->next(t2->next());
t2->next(r);
r = temp;
} else {
r = r->next();
}
}
}

cout << “ntTiempo promedio: ” << (float)tRT / n << endl;
cout << “ntQuantum: ” << Q << endl;

Leave a Reply

Your email address will not be published. Required fields are marked *