An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
April 19, 2024 09:20 pm GMT
Original Link: https://dev.to/imnotleo/priori-1km6
priori
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 << "
Id //" << " 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 << ""<< r -> id() << ""<< r -> tme()<< ""<< r -> prty()<< ""<< tR<< ""; 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); node *t = r; while(t -> next() != nullptr && t -> next() -> prty() == r -> prty()){ t = t -> next(); } r -> next(t -> next()); t -> next(r); cout << ""<< r -> id() << " no terminado"<< r -> tme()<< ""<< r -> prty()<< ""<< tR<< ""; cout << endl; } } cout << "
Tiempo promedio: "<< (float)tRT/n<< endl; cout << "
Quantum: "<< Q<< endl; }
Original Link: https://dev.to/imnotleo/priori-1km6
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To