Scheduler
conservativeGovernor.cpp
Go to the documentation of this file.
1 
10 #include "conservativeGovernor.h"
11 
12 #include <algorithm>
13 
14 #include <utils/log.h>
15 
16 #include <scheduler/time.h>
17 #include <scheduler/processor.h>
18 #include <scheduler/system.h>
19 
20 using namespace Scheduler;
21 
23  maxFreq(System::getInstance()->getProc()->getMaxFreq()), minFreq(System::getInstance()->getProc()->getMinFreq())
24 {
25 }
26 
27 void ConservativeGovernor::updateFreq(Processor *proc, Queue * /*readyQueue*/)
28 {
29  /*TODO not finished*/
30  double currentFreq = proc->getFreq();
31  if (proc->getUsage() > upThreshold)
32  {
33  currentFreq = std::min(maxFreq, currentFreq + freqStep*maxFreq);
34  }
35  else if (proc->getUsage() < downThreshold)
36  {
37  currentFreq = std::max(minFreq, currentFreq - freqStep*maxFreq);
38  }
39  proc->setFreq(currentFreq);
40 }
41 
43 {
44  return (trigger == freqUpdate);
45 }
46 
48 {
49  return "ConservativeGovernor";
50 }
TriggeringEvent
Definition: eventType.h:16
double getFreq() const
get the current frequency of the processor
Definition: processor.cpp:130
This class implements the ready queue and the wait queue. Those queues contain processes ready to run...
Definition: queue.h:28
bool freqChangeEvent(TriggeringEvent trigger)
double getUsage() const
get the current usage of the processor
Definition: processor.cpp:44
void setFreq(double)
set the current frequency of the processor
Definition: processor.cpp:121
void updateFreq(Processor *proc, Queue *readyQueue)