Scheduler
process.h
Go to the documentation of this file.
1 
10 #ifndef PROCESS_H
11 #define PROCESS_H
12 
13 #include <cmath>
14 #include <iterator>
15 #include <list>
16 #include <ostream>
17 #include <vector>
18 #include <memory>
19 
20 namespace Utils
21 {
22  class RandomGenerator;
23  class BoundedRandomDistribution;
24 }
25 
26 namespace Scheduler
27 {
28 
29 class Event;
30 
31 class Process
32 {
33 public:
36  static std::shared_ptr<Process> createNextJob(const Process& task);
43  static std::shared_ptr<Process> createProcess(double cpuLambda, double ioLambda);
52  static std::shared_ptr<Process> createRealTimeTask(double wcet, double T,
53  double dl, int pid, int priority = 0, double bcet = 0.0);
56  static int getNewPid();
61  static unsigned long int getMaxNumber();
64  static void setRandomGenerator(Utils::RandomGenerator *gen);
65 
68  //static void init();
69 
72  static void end();
73 private:
74  static const unsigned long int maxNumber = 4000000000;
75  static unsigned long int currentNumber;
76  static Utils::RandomGenerator *randomGenerator;
77 public:
78  /*FIXME: Why are those public?*/
79  Process(int pid, int nbBursts, std::vector<double> cpuBursts, std::vector<double> ioBursts, int priority = 0);
80  Process(const Process& task);
81  ~Process();
82 
83  void setDurationDistribution(std::shared_ptr<Utils::BoundedRandomDistribution> randomDist);
84  int getPid(void) const;
85  int getPriority() const;
86  void setPriority(int pri);
87  void updateCurrentAow(double aow);
88  bool advanceBurst();
89  void decrementBurst();
90  double getCurrentCpuAow() const;
91  double getCurrentIoTime() const;
92  void setRtParams(double dl, double T, double wcet, double bcet);
93  void setDeadlineTimeFromStartTime(double startTime);//TODO: how does this work with AOW?
94  bool isRealTime() const;
95  double getPeriod() const;
96  double getDeadline() const;
97  double getDeadlineTime() const;
98  void print(std::ostream& stream) const;
99  void incrementJobNumber();//TODO: Why is this public?
100  unsigned int getJobNumber() const;
101  double getWcet() const;
102  void setPowerCoeff(double);
103  double powerCoeff{1.0}; /*FIXME make this private*/
104 private:
105  /*Only for real-time jobs*/
106  void setDuration();
107 
108  int pid;
109  std::vector<double> cpuBurst;/*This is an array of aow. For RT jobs, this contains only one number*/
110  std::vector<double> ioBurst;/*This is an array of times spent waiting*/
111  int currentBurst{0};
112  int nbBursts; /*This is the nb of cpu bursts. there are n-1 io bursts.*/
113  int priority{0};
114 
115  /*Those are the real time parameters. Maybe would it be better to put them in an aggregated class*/
116  bool RT{false};
117  double deadline{0.0};
118  double deadlineTime{0.0};
119  double period{INFINITY};
120  unsigned int jobNumber{0};
121  double bcet{0.0}; /*best case execution time*/
122  double wcet{0.0}; /*XXX: wcet and bcet are expressed as amount of work and not in time units.*/
123  std::shared_ptr<Utils::BoundedRandomDistribution> randomDist{nullptr};
124 };
125 
126 
127 
128 
129 }
130 
131 
132 #endif
Definition: context.h:16