Scheduler
processor.h
Go to the documentation of this file.
1 
10 #ifndef PROCESSOR_H
11 #define PROCESSOR_H
12 
13 #include <string>
14 #include <memory>
15 
16 #include <utils/record.h>
17 #include <utils/configuration.h>
18 
19 #include "freqConstants.h"
21 
22 namespace Scheduler
23 {
24 
25 class Process;
26 class TemperatureModel;
27 
28 class Processor
29 {
30 public:
31  Processor(std::shared_ptr<Utils::Configuration>);
32  ~Processor();
35  double getFreq() const;
38  void setFreq(double);
41  double getMinFreq() const;
44  double getMaxFreq() const;
50  double getUsage() const;
53  void updateUsage();
54  void reinitTicks();
55  void updateTicks();
58  bool isRunning(std::shared_ptr<Process> p) const;
59  void setRunning(std::shared_ptr<Process> p);
60  std::shared_ptr<Process> getRunningTask();
63  void updateTemperature(double timeInterval);
64  double getTemperature() const;
65  void printReports(std::string folder) const;
66  void printTemperatureReport(std::string folder) const;
67  void printEnergyReport(std::string folder) const;
68  void printUsageReport(std::string folder) const;
69  void printFreqReport(std::string folder) const;
72  bool isBusy() const;
76  void power(bool p);
79  bool powered() const;
80 private:
81  std::shared_ptr<Utils::Configuration> conf;
82  const double maxFreq{MAXFREQ}; /*frequency in MHz*/
83  const double minFreq{MINFREQ};
84  double usage{0.0};
85  double freq{0.0};
86  std::shared_ptr<Process> runningTask{nullptr};
87  long long int totalBusyTicks{0};
88  long long int totalIdleTicks{0};
89  long long int previousIdleTicks{0};
90  long long int previousBusyTicks{0};
91  Utils::Record usageHistory;
92  Utils::Record freqHistory;
93  struct PowerParams powerParams;
94  TemperatureModel *temperatureModel{nullptr};
95 
96  bool busy{false};
97 };
98 
99 }
100 
101 #endif
double getMinFreq() const
get the minimum frequency at which this processor can operate
Definition: processor.cpp:39
double getFreq() const
get the current frequency of the processor
Definition: processor.cpp:130
#define MAXFREQ
Definition: freqConstants.h:16
void printEnergyReport(std::string folder) const
Definition: processor.cpp:142
TemperatureModel * getTemperatureModel()
Definition: processor.cpp:116
void updateUsage()
updates the value of the usage percentage.
Definition: processor.cpp:49
void setRunning(std::shared_ptr< Process > p)
Definition: processor.cpp:84
void printTemperatureReport(std::string folder) const
Definition: processor.cpp:137
bool isBusy() const
return true if the processor is running any task
Definition: processor.cpp:72
Processor(std::shared_ptr< Utils::Configuration >)
Definition: processor.cpp:25
double getTemperature() const
Definition: processor.cpp:185
double getUsage() const
get the current usage of the processor
Definition: processor.cpp:44
void printFreqReport(std::string folder) const
Definition: processor.cpp:155
void printUsageReport(std::string folder) const
Definition: processor.cpp:150
void power(bool p)
power the processor on or off
Definition: processor.cpp:174
void setFreq(double)
set the current frequency of the processor
Definition: processor.cpp:121
void updateTemperature(double timeInterval)
Definition: processor.cpp:100
bool powered() const
return true if the processor is powered on
Definition: processor.cpp:179
double getMaxFreq() const
get the maximum frequency at which this processor can operate
Definition: processor.cpp:34
#define MINFREQ
Definition: freqConstants.h:15
std::shared_ptr< Process > getRunningTask()
Definition: processor.cpp:92
void printReports(std::string folder) const
Definition: processor.cpp:160
void setTemperatureModel(TemperatureModel *)
Definition: processor.cpp:111
bool isRunning(std::shared_ptr< Process > p) const
returns true if the processor is running the task provided as argument
Definition: processor.cpp:78