Scheduler
actions.cpp
Go to the documentation of this file.
1 
10 #include "actions.h"
11 
12 #include <cassert>
13 
14 #include <scheduler/process.h>
15 #include <scheduler/queue.h>
16 
17 #include "domainModel.h"
18 
19 using namespace RlScheduler;
20 
21 
22 Action::Action(int pid) : id(pid)
23 {
24 }
25 
26 
28 {
29 }
30 
31 
32 std::shared_ptr<Scheduler::Process> Action::getProcessToRun()
33 {
34  //std::cout << "RL algo selected process "<<id<<"\n";
35  std::shared_ptr<DomainModel> model = getModel<DomainModel>();
36  std::shared_ptr<Scheduler::Process> process;
37  if (model->running != nullptr && model->running->getPid() == id)
38  return model->running;
39  for (auto it = model->readyQueue->begin(); it != model->readyQueue->end(); it++)
40  {
41  assert((*it) != nullptr);
42  if ( (*it)->getPid() == id)
43  return (*it);
44  }
45  return process;
46 }
47 
48 std::string Action::getName()
49 {
50  return ("scheduling process " + id);
51 }
52 
53 
54 
55 
56 
57 
58 
59 
60 
62 {
63 }
64 
65 
67 {
68 }
69 
70 std::string SleepAction::getName()
71 {
72  return "sleep";
73 }
74 
75 
76 std::shared_ptr<Scheduler::Process> SleepAction::getProcessToRun()
77 {
78  return nullptr;
79 }
80 
81 
82 
83 
84 
85 
std::string getName() override
Definition: actions.cpp:48
std::string getName() override
Definition: actions.cpp:70
std::shared_ptr< Scheduler::Process > getProcessToRun() override
returns the process to run according to the RL algorithm
Definition: actions.cpp:76
void performAction() override
Definition: actions.cpp:66
void performAction() override
Definition: actions.cpp:27
virtual std::shared_ptr< Scheduler::Process > getProcessToRun()
returns the process to run according to the RL algorithm
Definition: actions.cpp:32