sched_rsjf.h 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __SCHED_RSJF__
  2. #define __SCHED_RSJF__
  3. #include <map>
  4. #include <vector>
  5. #include <queue>
  6. #include <algorithm>
  7. #include <iostream>
  8. #include "basesched.h"
  9. using namespace std;
  10. class SchedRSJF : public SchedBase {
  11. public:
  12. SchedRSJF(std::vector<int> argn);
  13. ~SchedRSJF();
  14. virtual void initialize() {};
  15. virtual void load(int pid);
  16. virtual void unblock(int pid);
  17. virtual int next_process(int pid);
  18. virtual int tick(int cpu, const enum Motivo m);
  19. private:
  20. uint nucleos;
  21. uint* quantums;
  22. struct Process {
  23. int pid;
  24. uint duration;
  25. uint quantum_count;
  26. // Esto permite ordenar por la duración mínima
  27. int operator()(const Process& me, const Process& other) {
  28. cout << "Duration: " << me.duration << " < " << other.duration << "\n";
  29. return me.duration > other.duration;
  30. }
  31. };
  32. std::map<int, Process> p_map; // Mapeo de los procesos
  33. std::priority_queue<Process, std::vector<Process>, Process> pq; // Procesos en estado READY o RUNNING
  34. };
  35. #endif