diff options
| author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-04-11 11:00:35 -0400 |
|---|---|---|
| committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-04-11 11:00:35 -0400 |
| commit | 7f5bca0f5d1c1bfc56c83e248360720ef45c842a (patch) | |
| tree | 542dc955de70f2d573de50848680046f923029e0 | |
| parent | 20f6bc1e25b366c55fb95fb084ded37407042071 (diff) | |
Rename time types used in C++ schedulablity analysis
integral_t == integral time units
fractional_t == fractions of integral time units
This is hopefully less of an eyesore than mpq_class and mpz_class.
| -rw-r--r-- | native/include/edf/baker.h | 4 | ||||
| -rw-r--r-- | native/include/edf/baruah.h | 16 | ||||
| -rw-r--r-- | native/include/edf/bcl.h | 2 | ||||
| -rw-r--r-- | native/include/edf/ffdbf.h | 6 | ||||
| -rw-r--r-- | native/include/edf/load.h | 2 | ||||
| -rw-r--r-- | native/include/math-helper.h | 6 | ||||
| -rw-r--r-- | native/include/tasks.h | 34 | ||||
| -rw-r--r-- | native/include/time-types.h | 15 | ||||
| -rw-r--r-- | native/interface/sched.i | 6 | ||||
| -rw-r--r-- | native/interface/sim.i | 6 | ||||
| -rw-r--r-- | native/src/edf/baker.cpp | 12 | ||||
| -rw-r--r-- | native/src/edf/baruah.cpp | 76 | ||||
| -rw-r--r-- | native/src/edf/bcl.cpp | 8 | ||||
| -rw-r--r-- | native/src/edf/bcl_iterative.cpp | 8 | ||||
| -rw-r--r-- | native/src/edf/ffdbf.cpp | 68 | ||||
| -rw-r--r-- | native/src/edf/gedf.cpp | 2 | ||||
| -rw-r--r-- | native/src/edf/gfb.cpp | 2 | ||||
| -rw-r--r-- | native/src/edf/load.cpp | 4 | ||||
| -rw-r--r-- | native/src/edf/rta.cpp | 16 | ||||
| -rw-r--r-- | native/src/sharedres.cpp | 2 | ||||
| -rw-r--r-- | native/src/tasks.cpp | 38 | ||||
| -rw-r--r-- | native/src/testmain.cpp | 14 |
22 files changed, 178 insertions, 169 deletions
diff --git a/native/include/edf/baker.h b/native/include/edf/baker.h index c3716df..44493e5 100644 --- a/native/include/edf/baker.h +++ b/native/include/edf/baker.h | |||
| @@ -8,8 +8,8 @@ class BakerGedf : public SchedulabilityTest | |||
| 8 | unsigned int m; | 8 | unsigned int m; |
| 9 | 9 | ||
| 10 | private: | 10 | private: |
| 11 | void beta(const Task &t_i, const Task &t_k, const mpq_class &lambda_k, | 11 | void beta(const Task &t_i, const Task &t_k, const fractional_t &lambda_k, |
| 12 | mpq_class &beta_i); | 12 | fractional_t &beta_i); |
| 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); | 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); |
| 14 | 14 | ||
| 15 | public: | 15 | public: |
diff --git a/native/include/edf/baruah.h b/native/include/edf/baruah.h index c79b49d..f6f9217 100644 --- a/native/include/edf/baruah.h +++ b/native/include/edf/baruah.h | |||
| @@ -9,14 +9,14 @@ private: | |||
| 9 | 9 | ||
| 10 | bool is_task_schedulable(unsigned int k, | 10 | bool is_task_schedulable(unsigned int k, |
| 11 | const TaskSet &ts, | 11 | const TaskSet &ts, |
| 12 | const mpz_class &ilen, | 12 | const integral_t &ilen, |
| 13 | mpz_class &i1, | 13 | integral_t &i1, |
| 14 | mpz_class &sum, | 14 | integral_t &sum, |
| 15 | mpz_class *idiff, | 15 | integral_t *idiff, |
| 16 | mpz_class **ptr); | 16 | integral_t **ptr); |
| 17 | 17 | ||
| 18 | void get_max_test_points(const TaskSet &ts, mpq_class& m_minus_u, | 18 | void get_max_test_points(const TaskSet &ts, fractional_t& m_minus_u, |
| 19 | mpz_class* maxp); | 19 | integral_t* maxp); |
| 20 | 20 | ||
| 21 | public: | 21 | public: |
| 22 | BaruahGedf(unsigned int num_processors) : m(num_processors) {}; | 22 | BaruahGedf(unsigned int num_processors) : m(num_processors) {}; |
diff --git a/native/include/edf/bcl.h b/native/include/edf/bcl.h index 31bf1e3..aa4d818 100644 --- a/native/include/edf/bcl.h +++ b/native/include/edf/bcl.h | |||
| @@ -9,7 +9,7 @@ class BCLGedf : public SchedulabilityTest | |||
| 9 | 9 | ||
| 10 | private: | 10 | private: |
| 11 | unsigned long max_jobs_contained(const Task &t_i, const Task &t_k); | 11 | unsigned long max_jobs_contained(const Task &t_i, const Task &t_k); |
| 12 | void beta(const Task &t_i, const Task &t_k, mpq_class &beta_i); | 12 | void beta(const Task &t_i, const Task &t_k, fractional_t &beta_i); |
| 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); | 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); |
| 14 | 14 | ||
| 15 | public: | 15 | public: |
diff --git a/native/include/edf/ffdbf.h b/native/include/edf/ffdbf.h index 7e3dac6..a5fb834 100644 --- a/native/include/edf/ffdbf.h +++ b/native/include/edf/ffdbf.h | |||
| @@ -6,12 +6,12 @@ class FFDBFGedf : public SchedulabilityTest | |||
| 6 | private: | 6 | private: |
| 7 | const unsigned int m; | 7 | const unsigned int m; |
| 8 | const unsigned long epsilon_denom; | 8 | const unsigned long epsilon_denom; |
| 9 | const mpq_class sigma_step; | 9 | const fractional_t sigma_step; |
| 10 | 10 | ||
| 11 | private: | 11 | private: |
| 12 | bool witness_condition(const TaskSet &ts, | 12 | bool witness_condition(const TaskSet &ts, |
| 13 | const mpz_class q[], const mpq_class r[], | 13 | const integral_t q[], const fractional_t r[], |
| 14 | const mpq_class &time, const mpq_class &speed); | 14 | const fractional_t &time, const fractional_t &speed); |
| 15 | 15 | ||
| 16 | public: | 16 | public: |
| 17 | FFDBFGedf(unsigned int num_processors, | 17 | FFDBFGedf(unsigned int num_processors, |
diff --git a/native/include/edf/load.h b/native/include/edf/load.h index 36c8f5a..50d7850 100644 --- a/native/include/edf/load.h +++ b/native/include/edf/load.h | |||
| @@ -5,7 +5,7 @@ class LoadGedf : public SchedulabilityTest | |||
| 5 | { | 5 | { |
| 6 | private: | 6 | private: |
| 7 | unsigned int m; | 7 | unsigned int m; |
| 8 | mpq_class epsilon; | 8 | fractional_t epsilon; |
| 9 | 9 | ||
| 10 | public: | 10 | public: |
| 11 | LoadGedf(unsigned int num_processors, | 11 | LoadGedf(unsigned int num_processors, |
diff --git a/native/include/math-helper.h b/native/include/math-helper.h index 10c42c2..063558c 100644 --- a/native/include/math-helper.h +++ b/native/include/math-helper.h | |||
| @@ -1,12 +1,6 @@ | |||
| 1 | #ifndef MATH_HELPER_H | 1 | #ifndef MATH_HELPER_H |
| 2 | #define MATH_HELPER_H | 2 | #define MATH_HELPER_H |
| 3 | 3 | ||
| 4 | static inline void mpq_truncate(mpq_class &val) | ||
| 5 | { | ||
| 6 | val.get_num() -= val.get_num() % val.get_den(); | ||
| 7 | val.canonicalize(); | ||
| 8 | } | ||
| 9 | |||
| 10 | static inline unsigned long divide_with_ceil(unsigned long numer, | 4 | static inline unsigned long divide_with_ceil(unsigned long numer, |
| 11 | unsigned long denom) | 5 | unsigned long denom) |
| 12 | { | 6 | { |
diff --git a/native/include/tasks.h b/native/include/tasks.h index 175206a..dbba8d1 100644 --- a/native/include/tasks.h +++ b/native/include/tasks.h | |||
| @@ -6,10 +6,10 @@ | |||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | 8 | ||
| 9 | #include <gmpxx.h> | ||
| 10 | |||
| 11 | #include <math.h> | 9 | #include <math.h> |
| 12 | 10 | ||
| 11 | #include "time-types.h" | ||
| 12 | |||
| 13 | #endif | 13 | #endif |
| 14 | 14 | ||
| 15 | class Task | 15 | class Task |
| @@ -43,8 +43,8 @@ class Task | |||
| 43 | bool is_feasible() const; | 43 | bool is_feasible() const; |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | void get_utilization(mpq_class &util) const; | 46 | void get_utilization(fractional_t &util) const; |
| 47 | void get_density(mpq_class &density) const; | 47 | void get_density(fractional_t &density) const; |
| 48 | 48 | ||
| 49 | // Demand bound function (DBF) and LOAD support. | 49 | // Demand bound function (DBF) and LOAD support. |
| 50 | // This implements Fisher, Baker, and Baruah's PTAS | 50 | // This implements Fisher, Baker, and Baruah's PTAS |
| @@ -64,7 +64,7 @@ class Task | |||
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | void bound_demand(const mpz_class &time, mpz_class &demand) const | 67 | void bound_demand(const integral_t &time, integral_t &demand) const |
| 68 | { | 68 | { |
| 69 | if (time <= deadline) | 69 | if (time <= deadline) |
| 70 | demand = 0; | 70 | demand = 0; |
| @@ -79,9 +79,9 @@ class Task | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | void bound_load(const mpz_class &time, mpq_class &load) const | 82 | void bound_load(const integral_t &time, fractional_t &load) const |
| 83 | { | 83 | { |
| 84 | mpz_class demand; | 84 | integral_t demand; |
| 85 | 85 | ||
| 86 | if (time > 0) | 86 | if (time > 0) |
| 87 | { | 87 | { |
| @@ -107,14 +107,14 @@ class Task | |||
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | void approx_demand(const mpz_class &time, mpz_class &demand, | 110 | void approx_demand(const integral_t &time, integral_t &demand, |
| 111 | unsigned int k) const | 111 | unsigned int k) const |
| 112 | { | 112 | { |
| 113 | if (time < k * period + deadline) | 113 | if (time < k * period + deadline) |
| 114 | bound_demand(time, demand); | 114 | bound_demand(time, demand); |
| 115 | else | 115 | else |
| 116 | { | 116 | { |
| 117 | mpz_class approx; | 117 | integral_t approx; |
| 118 | 118 | ||
| 119 | approx = time; | 119 | approx = time; |
| 120 | approx -= deadline; | 120 | approx -= deadline; |
| @@ -126,10 +126,10 @@ class Task | |||
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | void approx_load(const mpz_class &time, mpq_class &load, | 129 | void approx_load(const integral_t &time, fractional_t &load, |
| 130 | unsigned int k) const | 130 | unsigned int k) const |
| 131 | { | 131 | { |
| 132 | mpz_class demand; | 132 | integral_t demand; |
| 133 | 133 | ||
| 134 | if (time > 0) | 134 | if (time > 0) |
| 135 | { | 135 | { |
| @@ -148,8 +148,8 @@ class TaskSet | |||
| 148 | { | 148 | { |
| 149 | private: | 149 | private: |
| 150 | Tasks tasks; | 150 | Tasks tasks; |
| 151 | 151 | ||
| 152 | unsigned long k_for_epsilon(unsigned int idx, const mpq_class &epsilon) const; | 152 | unsigned long k_for_epsilon(unsigned int idx, const fractional_t &epsilon) const; |
| 153 | 153 | ||
| 154 | public: | 154 | public: |
| 155 | TaskSet(); | 155 | TaskSet(); |
| @@ -172,11 +172,11 @@ class TaskSet | |||
| 172 | bool has_only_feasible_tasks() const; | 172 | bool has_only_feasible_tasks() const; |
| 173 | bool is_not_overutilized(unsigned int num_processors) const; | 173 | bool is_not_overutilized(unsigned int num_processors) const; |
| 174 | 174 | ||
| 175 | void get_utilization(mpq_class &util) const; | 175 | void get_utilization(fractional_t &util) const; |
| 176 | void get_density(mpq_class &density) const; | 176 | void get_density(fractional_t &density) const; |
| 177 | void get_max_density(mpq_class &max_density) const; | 177 | void get_max_density(fractional_t &max_density) const; |
| 178 | 178 | ||
| 179 | void approx_load(mpq_class &load, const mpq_class &epsilon = 0.1) const; | 179 | void approx_load(fractional_t &load, const fractional_t &epsilon = 0.1) const; |
| 180 | 180 | ||
| 181 | /* wrapper for Python access */ | 181 | /* wrapper for Python access */ |
| 182 | unsigned long get_period(unsigned int idx) const | 182 | unsigned long get_period(unsigned int idx) const |
diff --git a/native/include/time-types.h b/native/include/time-types.h new file mode 100644 index 0000000..a2250d3 --- /dev/null +++ b/native/include/time-types.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #ifndef TIME_TYPES_H | ||
| 2 | #define TIME_TYPES_H | ||
| 3 | |||
| 4 | #include <gmpxx.h> | ||
| 5 | |||
| 6 | typedef mpz_class integral_t; | ||
| 7 | typedef mpq_class fractional_t; | ||
| 8 | |||
| 9 | static inline void truncate_fraction(fractional_t &val) | ||
| 10 | { | ||
| 11 | val.get_num() -= val.get_num() % val.get_den(); | ||
| 12 | val.canonicalize(); | ||
| 13 | } | ||
| 14 | |||
| 15 | #endif | ||
diff --git a/native/interface/sched.i b/native/interface/sched.i index e94b5ca..255531a 100644 --- a/native/interface/sched.i +++ b/native/interface/sched.i | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | #include "sharedres.h" | 15 | #include "sharedres.h" |
| 16 | %} | 16 | %} |
| 17 | 17 | ||
| 18 | %ignore Task::get_utilization(mpq_class &util) const; | 18 | %ignore Task::get_utilization(fractional_t &util) const; |
| 19 | %ignore Task::get_density(mpq_class &density) const; | 19 | %ignore Task::get_density(fractional_t &density) const; |
| 20 | %ignore Task::bound_demand(const mpz_class &time, mpz_class &demand) const; | 20 | %ignore Task::bound_demand(const integral_t &time, integral_t &demand) const; |
| 21 | %ignore Task::bound_load const; | 21 | %ignore Task::bound_load const; |
| 22 | %ignore Task::approx_demand const; | 22 | %ignore Task::approx_demand const; |
| 23 | 23 | ||
diff --git a/native/interface/sim.i b/native/interface/sim.i index 26eac5f..aeeb59e 100644 --- a/native/interface/sim.i +++ b/native/interface/sim.i | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | #include "edf/sim.h" | 5 | #include "edf/sim.h" |
| 6 | %} | 6 | %} |
| 7 | 7 | ||
| 8 | %ignore Task::get_utilization(mpq_class &util) const; | 8 | %ignore Task::get_utilization(fractional_t &util) const; |
| 9 | %ignore Task::get_density(mpq_class &density) const; | 9 | %ignore Task::get_density(fractional_t &density) const; |
| 10 | %ignore Task::bound_demand(const mpz_class &time, mpz_class &demand) const; | 10 | %ignore Task::bound_demand(const integral_t &time, integral_t &demand) const; |
| 11 | %ignore Task::bound_load const; | 11 | %ignore Task::bound_load const; |
| 12 | %ignore Task::approx_demand const; | 12 | %ignore Task::approx_demand const; |
| 13 | 13 | ||
diff --git a/native/src/edf/baker.cpp b/native/src/edf/baker.cpp index ca2b8cc..3d13b2c 100644 --- a/native/src/edf/baker.cpp +++ b/native/src/edf/baker.cpp | |||
| @@ -8,10 +8,10 @@ | |||
| 8 | using namespace std; | 8 | using namespace std; |
| 9 | 9 | ||
| 10 | void BakerGedf::beta(const Task &t_i, const Task &t_k, | 10 | void BakerGedf::beta(const Task &t_i, const Task &t_k, |
| 11 | const mpq_class &lambda_k, | 11 | const fractional_t &lambda_k, |
| 12 | mpq_class &beta_i) | 12 | fractional_t &beta_i) |
| 13 | { | 13 | { |
| 14 | mpq_class u_i; | 14 | fractional_t u_i; |
| 15 | 15 | ||
| 16 | // XXX: possible improvement would be to pre-compute u_i | 16 | // XXX: possible improvement would be to pre-compute u_i |
| 17 | // instead of incurring quadratic u_i computations. | 17 | // instead of incurring quadratic u_i computations. |
| @@ -24,7 +24,7 @@ void BakerGedf::beta(const Task &t_i, const Task &t_k, | |||
| 24 | 24 | ||
| 25 | if (lambda_k < u_i) | 25 | if (lambda_k < u_i) |
| 26 | { | 26 | { |
| 27 | mpq_class tmp = t_i.get_wcet(); | 27 | fractional_t tmp = t_i.get_wcet(); |
| 28 | tmp -= lambda_k * t_i.get_period(); | 28 | tmp -= lambda_k * t_i.get_period(); |
| 29 | tmp /= t_k.get_deadline(); | 29 | tmp /= t_k.get_deadline(); |
| 30 | beta_i += tmp; | 30 | beta_i += tmp; |
| @@ -33,8 +33,8 @@ void BakerGedf::beta(const Task &t_i, const Task &t_k, | |||
| 33 | 33 | ||
| 34 | bool BakerGedf::is_task_schedulable(unsigned int k, const TaskSet &ts) | 34 | bool BakerGedf::is_task_schedulable(unsigned int k, const TaskSet &ts) |
| 35 | { | 35 | { |
| 36 | mpq_class lambda, bound, beta_i, beta_sum = 0; | 36 | fractional_t lambda, bound, beta_i, beta_sum = 0; |
| 37 | mpq_class one = 1; | 37 | fractional_t one = 1; |
| 38 | 38 | ||
| 39 | ts[k].get_density(lambda); | 39 | ts[k].get_density(lambda); |
| 40 | 40 | ||
diff --git a/native/src/edf/baruah.cpp b/native/src/edf/baruah.cpp index 1b82baa..d2699e5 100644 --- a/native/src/edf/baruah.cpp +++ b/native/src/edf/baruah.cpp | |||
| @@ -18,8 +18,8 @@ const double BaruahGedf::MAX_RUNTIME = 5.0; /* seconds */ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | static void demand_bound_function(const Task &tsk, | 20 | static void demand_bound_function(const Task &tsk, |
| 21 | const mpz_class &t, | 21 | const integral_t &t, |
| 22 | mpz_class &db) | 22 | integral_t &db) |
| 23 | { | 23 | { |
| 24 | db = t; | 24 | db = t; |
| 25 | db -= tsk.get_deadline(); | 25 | db -= tsk.get_deadline(); |
| @@ -36,7 +36,7 @@ static void demand_bound_function(const Task &tsk, | |||
| 36 | class DBFPointsOfChange | 36 | class DBFPointsOfChange |
| 37 | { | 37 | { |
| 38 | private: | 38 | private: |
| 39 | mpz_class cur; | 39 | integral_t cur; |
| 40 | unsigned long pi; // period | 40 | unsigned long pi; // period |
| 41 | 41 | ||
| 42 | public: | 42 | public: |
| @@ -56,7 +56,7 @@ public: | |||
| 56 | next(); | 56 | next(); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | const mpz_class& get_cur() const | 59 | const integral_t& get_cur() const |
| 60 | { | 60 | { |
| 61 | return cur; | 61 | return cur; |
| 62 | } | 62 | } |
| @@ -84,11 +84,11 @@ class AllDBFPointsOfChange | |||
| 84 | private: | 84 | private: |
| 85 | DBFPointsOfChange *dbf; | 85 | DBFPointsOfChange *dbf; |
| 86 | DBFQueue queue; | 86 | DBFQueue queue; |
| 87 | mpz_class last; | 87 | integral_t last; |
| 88 | mpz_class *upper_bound; | 88 | integral_t *upper_bound; |
| 89 | 89 | ||
| 90 | public: | 90 | public: |
| 91 | void init(const TaskSet &ts, int k, mpz_class* bound) | 91 | void init(const TaskSet &ts, int k, integral_t* bound) |
| 92 | { | 92 | { |
| 93 | last = -1; | 93 | last = -1; |
| 94 | dbf = new DBFPointsOfChange[ts.get_task_count()]; | 94 | dbf = new DBFPointsOfChange[ts.get_task_count()]; |
| @@ -105,7 +105,7 @@ public: | |||
| 105 | delete[] dbf; | 105 | delete[] dbf; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | bool get_next(mpz_class &t) | 108 | bool get_next(integral_t &t) |
| 109 | { | 109 | { |
| 110 | if (last > *upper_bound) | 110 | if (last > *upper_bound) |
| 111 | return false; | 111 | return false; |
| @@ -127,49 +127,49 @@ public: | |||
| 127 | 127 | ||
| 128 | static | 128 | static |
| 129 | void interval1(unsigned int i, unsigned int k, const TaskSet &ts, | 129 | void interval1(unsigned int i, unsigned int k, const TaskSet &ts, |
| 130 | const mpz_class &ilen, mpz_class &i1) | 130 | const integral_t &ilen, integral_t &i1) |
| 131 | { | 131 | { |
| 132 | mpz_class dbf, tmp; | 132 | integral_t dbf, tmp; |
| 133 | tmp = ilen + ts[k].get_deadline(); | 133 | tmp = ilen + ts[k].get_deadline(); |
| 134 | demand_bound_function(ts[i], tmp, dbf); | 134 | demand_bound_function(ts[i], tmp, dbf); |
| 135 | if (i == k) | 135 | if (i == k) |
| 136 | i1 = min(mpz_class(dbf - ts[k].get_wcet()), ilen); | 136 | i1 = min(integral_t(dbf - ts[k].get_wcet()), ilen); |
| 137 | else | 137 | else |
| 138 | i1 = min(dbf, | 138 | i1 = min(dbf, |
| 139 | mpz_class(ilen + ts[k].get_deadline() - | 139 | integral_t(ilen + ts[k].get_deadline() - |
| 140 | (ts[k].get_wcet() - 1))); | 140 | (ts[k].get_wcet() - 1))); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | 143 | ||
| 144 | static void demand_bound_function_prime(const Task &tsk, | 144 | static void demand_bound_function_prime(const Task &tsk, |
| 145 | const mpz_class &t, | 145 | const integral_t &t, |
| 146 | mpz_class &db) | 146 | integral_t &db) |
| 147 | // carry-in scenario | 147 | // carry-in scenario |
| 148 | { | 148 | { |
| 149 | db = t; | 149 | db = t; |
| 150 | db /= tsk.get_period(); | 150 | db /= tsk.get_period(); |
| 151 | db *= tsk.get_wcet(); | 151 | db *= tsk.get_wcet(); |
| 152 | db += min(mpz_class(tsk.get_wcet()), mpz_class(t % tsk.get_period())); | 152 | db += min(integral_t(tsk.get_wcet()), integral_t(t % tsk.get_period())); |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | static void interval2(unsigned int i, unsigned int k, const TaskSet &ts, | 155 | static void interval2(unsigned int i, unsigned int k, const TaskSet &ts, |
| 156 | const mpz_class &ilen, mpz_class &i2) | 156 | const integral_t &ilen, integral_t &i2) |
| 157 | { | 157 | { |
| 158 | mpz_class dbf, tmp; | 158 | integral_t dbf, tmp; |
| 159 | 159 | ||
| 160 | tmp = ilen + ts[k].get_deadline(); | 160 | tmp = ilen + ts[k].get_deadline(); |
| 161 | demand_bound_function_prime(ts[i], tmp, dbf); | 161 | demand_bound_function_prime(ts[i], tmp, dbf); |
| 162 | if (i == k) | 162 | if (i == k) |
| 163 | i2 = min(mpz_class(dbf - ts[k].get_wcet()), ilen); | 163 | i2 = min(integral_t(dbf - ts[k].get_wcet()), ilen); |
| 164 | else | 164 | else |
| 165 | i2 = min(dbf, | 165 | i2 = min(dbf, |
| 166 | mpz_class(ilen + ts[k].get_deadline() - | 166 | integral_t(ilen + ts[k].get_deadline() - |
| 167 | (ts[k].get_wcet() - 1))); | 167 | (ts[k].get_wcet() - 1))); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | class MPZComparator { | 170 | class MPZComparator { |
| 171 | public: | 171 | public: |
| 172 | bool operator() (mpz_class *a, mpz_class *b) | 172 | bool operator() (integral_t *a, integral_t *b) |
| 173 | { | 173 | { |
| 174 | return *b < *a; | 174 | return *b < *a; |
| 175 | } | 175 | } |
| @@ -177,13 +177,13 @@ public: | |||
| 177 | 177 | ||
| 178 | bool BaruahGedf::is_task_schedulable(unsigned int k, | 178 | bool BaruahGedf::is_task_schedulable(unsigned int k, |
| 179 | const TaskSet &ts, | 179 | const TaskSet &ts, |
| 180 | const mpz_class &ilen, | 180 | const integral_t &ilen, |
| 181 | mpz_class &i1, | 181 | integral_t &i1, |
| 182 | mpz_class &sum, | 182 | integral_t &sum, |
| 183 | mpz_class *idiff, | 183 | integral_t *idiff, |
| 184 | mpz_class **ptr) | 184 | integral_t **ptr) |
| 185 | { | 185 | { |
| 186 | mpz_class bound; | 186 | integral_t bound; |
| 187 | sum = 0; | 187 | sum = 0; |
| 188 | 188 | ||
| 189 | for (unsigned int i = 0; i < ts.get_task_count(); i++) | 189 | for (unsigned int i = 0; i < ts.get_task_count(); i++) |
| @@ -206,8 +206,8 @@ bool BaruahGedf::is_task_schedulable(unsigned int k, | |||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | void BaruahGedf::get_max_test_points(const TaskSet &ts, | 208 | void BaruahGedf::get_max_test_points(const TaskSet &ts, |
| 209 | mpq_class &m_minus_u, | 209 | fractional_t &m_minus_u, |
| 210 | mpz_class* maxp) | 210 | integral_t* maxp) |
| 211 | { | 211 | { |
| 212 | unsigned long* wcet = new unsigned long[ts.get_task_count()]; | 212 | unsigned long* wcet = new unsigned long[ts.get_task_count()]; |
| 213 | 213 | ||
| @@ -216,8 +216,8 @@ void BaruahGedf::get_max_test_points(const TaskSet &ts, | |||
| 216 | 216 | ||
| 217 | sort(wcet, wcet + ts.get_task_count(), greater<unsigned long>()); | 217 | sort(wcet, wcet + ts.get_task_count(), greater<unsigned long>()); |
| 218 | 218 | ||
| 219 | mpq_class u, tdu_sum; | 219 | fractional_t u, tdu_sum; |
| 220 | mpz_class csigma, mc; | 220 | integral_t csigma, mc; |
| 221 | 221 | ||
| 222 | csigma = 0; | 222 | csigma = 0; |
| 223 | for (unsigned int i = 0; i < m - 1 && i < ts.get_task_count(); i++) | 223 | for (unsigned int i = 0; i < m - 1 && i < ts.get_task_count(); i++) |
| @@ -256,7 +256,7 @@ bool BaruahGedf::is_schedulable(const TaskSet &ts, | |||
| 256 | return true; | 256 | return true; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | mpq_class m_minus_u; | 259 | fractional_t m_minus_u; |
| 260 | ts.get_utilization(m_minus_u); | 260 | ts.get_utilization(m_minus_u); |
| 261 | m_minus_u *= -1; | 261 | m_minus_u *= -1; |
| 262 | m_minus_u += m; | 262 | m_minus_u += m; |
| @@ -270,19 +270,19 @@ bool BaruahGedf::is_schedulable(const TaskSet &ts, | |||
| 270 | 270 | ||
| 271 | double start_time = get_cpu_usage(); | 271 | double start_time = get_cpu_usage(); |
| 272 | 272 | ||
| 273 | mpz_class i1, sum; | 273 | integral_t i1, sum; |
| 274 | mpz_class *max_test_point, *idiff; | 274 | integral_t *max_test_point, *idiff; |
| 275 | mpz_class** ptr; // indirect access to idiff | 275 | integral_t** ptr; // indirect access to idiff |
| 276 | 276 | ||
| 277 | idiff = new mpz_class[ts.get_task_count()]; | 277 | idiff = new integral_t[ts.get_task_count()]; |
| 278 | max_test_point = new mpz_class[ts.get_task_count()]; | 278 | max_test_point = new integral_t[ts.get_task_count()]; |
| 279 | ptr = new mpz_class*[ts.get_task_count()]; | 279 | ptr = new integral_t*[ts.get_task_count()]; |
| 280 | for (unsigned int i = 0; i < ts.get_task_count(); i++) | 280 | for (unsigned int i = 0; i < ts.get_task_count(); i++) |
| 281 | ptr[i] = idiff + i; | 281 | ptr[i] = idiff + i; |
| 282 | 282 | ||
| 283 | get_max_test_points(ts, m_minus_u, max_test_point); | 283 | get_max_test_points(ts, m_minus_u, max_test_point); |
| 284 | 284 | ||
| 285 | mpz_class ilen; | 285 | integral_t ilen; |
| 286 | bool point_in_range = true; | 286 | bool point_in_range = true; |
| 287 | bool schedulable = true; | 287 | bool schedulable = true; |
| 288 | 288 | ||
diff --git a/native/src/edf/bcl.cpp b/native/src/edf/bcl.cpp index 8cc25d9..d7fa721 100644 --- a/native/src/edf/bcl.cpp +++ b/native/src/edf/bcl.cpp | |||
| @@ -15,11 +15,11 @@ unsigned long BCLGedf::max_jobs_contained(const Task &t_i, const Task &t_k) | |||
| 15 | return 1 + (t_k.get_deadline() - t_i.get_deadline()) / t_i.get_period(); | 15 | return 1 + (t_k.get_deadline() - t_i.get_deadline()) / t_i.get_period(); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | void BCLGedf::beta(const Task &t_i, const Task &t_k, mpq_class &beta_i) | 18 | void BCLGedf::beta(const Task &t_i, const Task &t_k, fractional_t &beta_i) |
| 19 | { | 19 | { |
| 20 | unsigned long n = max_jobs_contained(t_i, t_k); | 20 | unsigned long n = max_jobs_contained(t_i, t_k); |
| 21 | 21 | ||
| 22 | mpz_class c_i, tmp; | 22 | integral_t c_i, tmp; |
| 23 | 23 | ||
| 24 | c_i = t_i.get_wcet(); | 24 | c_i = t_i.get_wcet(); |
| 25 | tmp = t_i.get_period(); | 25 | tmp = t_i.get_period(); |
| @@ -38,8 +38,8 @@ void BCLGedf::beta(const Task &t_i, const Task &t_k, mpq_class &beta_i) | |||
| 38 | 38 | ||
| 39 | bool BCLGedf::is_task_schedulable(unsigned int k, const TaskSet &ts) | 39 | bool BCLGedf::is_task_schedulable(unsigned int k, const TaskSet &ts) |
| 40 | { | 40 | { |
| 41 | mpq_class beta_i, beta_sum = 0; | 41 | fractional_t beta_i, beta_sum = 0; |
| 42 | mpq_class lambda_term; | 42 | fractional_t lambda_term; |
| 43 | bool small_beta_exists = false; | 43 | bool small_beta_exists = false; |
| 44 | 44 | ||
| 45 | ts[k].get_density(lambda_term); | 45 | ts[k].get_density(lambda_term); |
diff --git a/native/src/edf/bcl_iterative.cpp b/native/src/edf/bcl_iterative.cpp index e70c0c4..b8e58ef 100644 --- a/native/src/edf/bcl_iterative.cpp +++ b/native/src/edf/bcl_iterative.cpp | |||
| @@ -11,7 +11,7 @@ using namespace std; | |||
| 11 | static void interfering_workload(const Task &t_i, | 11 | static void interfering_workload(const Task &t_i, |
| 12 | const Task &t_k, | 12 | const Task &t_k, |
| 13 | unsigned long slack, | 13 | unsigned long slack, |
| 14 | mpz_class &inf) | 14 | integral_t &inf) |
| 15 | { | 15 | { |
| 16 | unsigned long njobs = t_k.get_deadline() / t_i.get_period(); | 16 | unsigned long njobs = t_k.get_deadline() / t_i.get_period(); |
| 17 | 17 | ||
| @@ -30,9 +30,9 @@ bool BCLIterativeGedf::slack_update(unsigned int k, | |||
| 30 | unsigned long *slack, | 30 | unsigned long *slack, |
| 31 | bool &has_slack) | 31 | bool &has_slack) |
| 32 | { | 32 | { |
| 33 | mpz_class other_work = 0; | 33 | integral_t other_work = 0; |
| 34 | mpz_class inf; | 34 | integral_t inf; |
| 35 | mpz_class inf_bound = ts[k].get_deadline() - ts[k].get_wcet() + 1; | 35 | integral_t inf_bound = ts[k].get_deadline() - ts[k].get_wcet() + 1; |
| 36 | 36 | ||
| 37 | for (unsigned int i = 0; i < ts.get_task_count(); i++) | 37 | for (unsigned int i = 0; i < ts.get_task_count(); i++) |
| 38 | if (k != i) | 38 | if (k != i) |
diff --git a/native/src/edf/ffdbf.cpp b/native/src/edf/ffdbf.cpp index a28ea38..fa64b96 100644 --- a/native/src/edf/ffdbf.cpp +++ b/native/src/edf/ffdbf.cpp | |||
| @@ -13,8 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | using namespace std; | 14 | using namespace std; |
| 15 | 15 | ||
| 16 | static void get_q_r(const Task &t_i, const mpq_class &time, | 16 | static void get_q_r(const Task &t_i, const fractional_t &time, |
| 17 | mpz_class &q_i, mpq_class &r_i) | 17 | integral_t &q_i, fractional_t &r_i) |
| 18 | { | 18 | { |
| 19 | // compute q_i -- floor(time / period) | 19 | // compute q_i -- floor(time / period) |
| 20 | // r_i -- time % period | 20 | // r_i -- time % period |
| @@ -26,18 +26,18 @@ static void get_q_r(const Task &t_i, const mpq_class &time, | |||
| 26 | r_i -= q_i * t_i.get_period(); | 26 | r_i -= q_i * t_i.get_period(); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | static void compute_q_r(const TaskSet &ts, const mpq_class &time, | 29 | static void compute_q_r(const TaskSet &ts, const fractional_t &time, |
| 30 | mpz_class q[], mpq_class r[]) | 30 | integral_t q[], fractional_t r[]) |
| 31 | { | 31 | { |
| 32 | for (unsigned int i = 0; i < ts.get_task_count(); i++) | 32 | for (unsigned int i = 0; i < ts.get_task_count(); i++) |
| 33 | get_q_r(ts[i], time, q[i], r[i]); | 33 | get_q_r(ts[i], time, q[i], r[i]); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | static void ffdbf(const Task &t_i, | 36 | static void ffdbf(const Task &t_i, |
| 37 | const mpq_class &time, const mpq_class &speed, | 37 | const fractional_t &time, const fractional_t &speed, |
| 38 | const mpz_class &q_i, const mpq_class &r_i, | 38 | const integral_t &q_i, const fractional_t &r_i, |
| 39 | mpq_class &demand, | 39 | fractional_t &demand, |
| 40 | mpq_class &tmp) | 40 | fractional_t &tmp) |
| 41 | { | 41 | { |
| 42 | /* this is the cost in all three cases */ | 42 | /* this is the cost in all three cases */ |
| 43 | demand += q_i * t_i.get_wcet(); | 43 | demand += q_i * t_i.get_wcet(); |
| @@ -64,9 +64,9 @@ static void ffdbf(const Task &t_i, | |||
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static void ffdbf_ts(const TaskSet &ts, | 66 | static void ffdbf_ts(const TaskSet &ts, |
| 67 | const mpz_class q[], const mpq_class r[], | 67 | const integral_t q[], const fractional_t r[], |
| 68 | const mpq_class &time, const mpq_class &speed, | 68 | const fractional_t &time, const fractional_t &speed, |
| 69 | mpq_class &demand, mpq_class &tmp) | 69 | fractional_t &demand, fractional_t &tmp) |
| 70 | { | 70 | { |
| 71 | demand = 0; | 71 | demand = 0; |
| 72 | for (unsigned int i = 0; i < ts.get_task_count(); i++) | 72 | for (unsigned int i = 0; i < ts.get_task_count(); i++) |
| @@ -77,15 +77,15 @@ static void ffdbf_ts(const TaskSet &ts, | |||
| 77 | class TestPoints | 77 | class TestPoints |
| 78 | { | 78 | { |
| 79 | private: | 79 | private: |
| 80 | mpq_class time; | 80 | fractional_t time; |
| 81 | mpq_class with_offset; | 81 | fractional_t with_offset; |
| 82 | unsigned long period; | 82 | unsigned long period; |
| 83 | bool first_point; | 83 | bool first_point; |
| 84 | 84 | ||
| 85 | public: | 85 | public: |
| 86 | void init(const Task& t_i, | 86 | void init(const Task& t_i, |
| 87 | const mpq_class& speed, | 87 | const fractional_t& speed, |
| 88 | const mpq_class& min_time) | 88 | const fractional_t& min_time) |
| 89 | { | 89 | { |
| 90 | period = t_i.get_period(); | 90 | period = t_i.get_period(); |
| 91 | with_offset = t_i.get_wcet() / speed; | 91 | with_offset = t_i.get_wcet() / speed; |
| @@ -96,7 +96,7 @@ public: | |||
| 96 | time = min_time; | 96 | time = min_time; |
| 97 | time /= period; | 97 | time /= period; |
| 98 | // round down, i.e., floor() | 98 | // round down, i.e., floor() |
| 99 | mpq_truncate(time); | 99 | truncate_fraction(time); |
| 100 | time *= period; | 100 | time *= period; |
| 101 | time += t_i.get_deadline(); | 101 | time += t_i.get_deadline(); |
| 102 | 102 | ||
| @@ -107,7 +107,7 @@ public: | |||
| 107 | next(); | 107 | next(); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | const mpq_class& get_cur() const | 110 | const fractional_t& get_cur() const |
| 111 | { | 111 | { |
| 112 | if (first_point) | 112 | if (first_point) |
| 113 | return with_offset; | 113 | return with_offset; |
| @@ -145,7 +145,7 @@ class AllTestPoints | |||
| 145 | private: | 145 | private: |
| 146 | TestPoints *pts; | 146 | TestPoints *pts; |
| 147 | TimeQueue queue; | 147 | TimeQueue queue; |
| 148 | mpq_class last; | 148 | fractional_t last; |
| 149 | TaskSet const &ts; | 149 | TaskSet const &ts; |
| 150 | 150 | ||
| 151 | public: | 151 | public: |
| @@ -155,8 +155,8 @@ public: | |||
| 155 | pts = new TestPoints[ts.get_task_count()]; | 155 | pts = new TestPoints[ts.get_task_count()]; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | void init(const mpq_class &speed, | 158 | void init(const fractional_t &speed, |
| 159 | const mpq_class &min_time) | 159 | const fractional_t &min_time) |
| 160 | { | 160 | { |
| 161 | last = -1; | 161 | last = -1; |
| 162 | // clean out queue | 162 | // clean out queue |
| @@ -175,7 +175,7 @@ public: | |||
| 175 | delete[] pts; | 175 | delete[] pts; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | void get_next(mpq_class &t) | 178 | void get_next(fractional_t &t) |
| 179 | { | 179 | { |
| 180 | TestPoints* pt; | 180 | TestPoints* pt; |
| 181 | do // avoid duplicates | 181 | do // avoid duplicates |
| @@ -191,11 +191,11 @@ public: | |||
| 191 | }; | 191 | }; |
| 192 | 192 | ||
| 193 | bool FFDBFGedf::witness_condition(const TaskSet &ts, | 193 | bool FFDBFGedf::witness_condition(const TaskSet &ts, |
| 194 | const mpz_class q[], const mpq_class r[], | 194 | const integral_t q[], const fractional_t r[], |
| 195 | const mpq_class &time, | 195 | const fractional_t &time, |
| 196 | const mpq_class &speed) | 196 | const fractional_t &speed) |
| 197 | { | 197 | { |
| 198 | mpq_class demand, bound; | 198 | fractional_t demand, bound; |
| 199 | 199 | ||
| 200 | ffdbf_ts(ts, q, r, time, speed, demand, bound); | 200 | ffdbf_ts(ts, q, r, time, speed, demand, bound); |
| 201 | 201 | ||
| @@ -223,12 +223,12 @@ bool FFDBFGedf::is_schedulable(const TaskSet &ts, | |||
| 223 | 223 | ||
| 224 | // allocate helpers | 224 | // allocate helpers |
| 225 | AllTestPoints testing_set(ts); | 225 | AllTestPoints testing_set(ts); |
| 226 | mpz_class *q = new mpz_class[ts.get_task_count()]; | 226 | integral_t *q = new integral_t[ts.get_task_count()]; |
| 227 | mpq_class *r = new mpq_class[ts.get_task_count()]; | 227 | fractional_t *r = new fractional_t[ts.get_task_count()]; |
| 228 | 228 | ||
| 229 | mpq_class sigma_bound; | 229 | fractional_t sigma_bound; |
| 230 | mpq_class time_bound; | 230 | fractional_t time_bound; |
| 231 | mpq_class tmp(1, epsilon_denom); | 231 | fractional_t tmp(1, epsilon_denom); |
| 232 | 232 | ||
| 233 | // compute sigma bound | 233 | // compute sigma bound |
| 234 | tmp = 1; | 234 | tmp = 1; |
| @@ -237,7 +237,7 @@ bool FFDBFGedf::is_schedulable(const TaskSet &ts, | |||
| 237 | sigma_bound -= m; | 237 | sigma_bound -= m; |
| 238 | sigma_bound /= - ((int) (m - 1)); // neg. to flip sign | 238 | sigma_bound /= - ((int) (m - 1)); // neg. to flip sign |
| 239 | sigma_bound -= tmp; // epsilon | 239 | sigma_bound -= tmp; // epsilon |
| 240 | sigma_bound = min(sigma_bound, mpq_class(1)); | 240 | sigma_bound = min(sigma_bound, fractional_t(1)); |
| 241 | 241 | ||
| 242 | // compute time bound | 242 | // compute time bound |
| 243 | time_bound = 0; | 243 | time_bound = 0; |
| @@ -245,8 +245,8 @@ bool FFDBFGedf::is_schedulable(const TaskSet &ts, | |||
| 245 | time_bound += ts[i].get_wcet(); | 245 | time_bound += ts[i].get_wcet(); |
| 246 | time_bound /= tmp; // epsilon | 246 | time_bound /= tmp; // epsilon |
| 247 | 247 | ||
| 248 | mpq_class t_cur; | 248 | fractional_t t_cur; |
| 249 | mpq_class sigma_cur, sigma_nxt; | 249 | fractional_t sigma_cur, sigma_nxt; |
| 250 | bool schedulable; | 250 | bool schedulable; |
| 251 | 251 | ||
| 252 | t_cur = 0; | 252 | t_cur = 0; |
| @@ -258,7 +258,7 @@ bool FFDBFGedf::is_schedulable(const TaskSet &ts, | |||
| 258 | 258 | ||
| 259 | // setup brute force sigma value range | 259 | // setup brute force sigma value range |
| 260 | sigma_nxt = sigma_cur / sigma_step; | 260 | sigma_nxt = sigma_cur / sigma_step; |
| 261 | mpq_truncate(sigma_nxt); | 261 | truncate_fraction(sigma_nxt); |
| 262 | sigma_nxt += 1; | 262 | sigma_nxt += 1; |
| 263 | sigma_nxt *= sigma_step; | 263 | sigma_nxt *= sigma_step; |
| 264 | 264 | ||
diff --git a/native/src/edf/gedf.cpp b/native/src/edf/gedf.cpp index 35f1847..e2a6bec 100644 --- a/native/src/edf/gedf.cpp +++ b/native/src/edf/gedf.cpp | |||
| @@ -26,7 +26,7 @@ bool GlobalEDF::is_schedulable(const TaskSet &ts, | |||
| 26 | // density bound on a uniprocessor. | 26 | // density bound on a uniprocessor. |
| 27 | if (m == 1) | 27 | if (m == 1) |
| 28 | { | 28 | { |
| 29 | mpq_class density; | 29 | fractional_t density; |
| 30 | ts.get_density(density); | 30 | ts.get_density(density); |
| 31 | if (density <= 1) | 31 | if (density <= 1) |
| 32 | return true; | 32 | return true; |
diff --git a/native/src/edf/gfb.cpp b/native/src/edf/gfb.cpp index 0aa90b8..822b97b 100644 --- a/native/src/edf/gfb.cpp +++ b/native/src/edf/gfb.cpp | |||
| @@ -13,7 +13,7 @@ bool GFBGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) | |||
| 13 | return false; | 13 | return false; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | mpq_class total_density, max_density, bound; | 16 | fractional_t total_density, max_density, bound; |
| 17 | 17 | ||
| 18 | ts.get_density(total_density); | 18 | ts.get_density(total_density); |
| 19 | ts.get_max_density(max_density); | 19 | ts.get_max_density(max_density); |
diff --git a/native/src/edf/load.cpp b/native/src/edf/load.cpp index 38d3c55..db44d20 100644 --- a/native/src/edf/load.cpp +++ b/native/src/edf/load.cpp | |||
| @@ -22,8 +22,8 @@ bool LoadGedf::is_schedulable(const TaskSet &ts, bool check_preconditions) | |||
| 22 | return false; | 22 | return false; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | mpq_class load, max_density, mu, bound, cond1, cond2; | 25 | fractional_t load, max_density, mu, bound, cond1, cond2; |
| 26 | mpz_class mu_ceil; | 26 | integral_t mu_ceil; |
| 27 | 27 | ||
| 28 | // get the load of the task set | 28 | // get the load of the task set |
| 29 | ts.approx_load(load, epsilon); | 29 | ts.approx_load(load, epsilon); |
diff --git a/native/src/edf/rta.cpp b/native/src/edf/rta.cpp index 68eafa6..4114467 100644 --- a/native/src/edf/rta.cpp +++ b/native/src/edf/rta.cpp | |||
| @@ -15,8 +15,8 @@ using namespace std; | |||
| 15 | static void rta_interfering_workload(const Task &t_i, | 15 | static void rta_interfering_workload(const Task &t_i, |
| 16 | unsigned long response_time, | 16 | unsigned long response_time, |
| 17 | unsigned long slack_i, | 17 | unsigned long slack_i, |
| 18 | mpz_class &inf, | 18 | integral_t &inf, |
| 19 | mpz_class &interval) | 19 | integral_t &interval) |
| 20 | { | 20 | { |
| 21 | interval = response_time; | 21 | interval = response_time; |
| 22 | interval += t_i.get_deadline() - t_i.get_wcet(); | 22 | interval += t_i.get_deadline() - t_i.get_wcet(); |
| @@ -36,7 +36,7 @@ static void rta_interfering_workload(const Task &t_i, | |||
| 36 | static void edf_interfering_workload(const Task &t_i, | 36 | static void edf_interfering_workload(const Task &t_i, |
| 37 | const Task &t_k, | 37 | const Task &t_k, |
| 38 | unsigned long slack_i, | 38 | unsigned long slack_i, |
| 39 | mpz_class &inf) | 39 | integral_t &inf) |
| 40 | { | 40 | { |
| 41 | /* implicit floor in integer division */ | 41 | /* implicit floor in integer division */ |
| 42 | unsigned long njobs = t_k.get_deadline() / t_i.get_period(); | 42 | unsigned long njobs = t_k.get_deadline() / t_i.get_period(); |
| @@ -56,11 +56,11 @@ bool RTAGedf::response_estimate(unsigned int k, | |||
| 56 | unsigned long response, | 56 | unsigned long response, |
| 57 | unsigned long &new_response) | 57 | unsigned long &new_response) |
| 58 | { | 58 | { |
| 59 | mpz_class other_work = 0; | 59 | integral_t other_work = 0; |
| 60 | mpz_class inf_edf; | 60 | integral_t inf_edf; |
| 61 | mpz_class inf_rta; | 61 | integral_t inf_rta; |
| 62 | mpz_class inf_bound = response - ts[k].get_wcet() + 1; | 62 | integral_t inf_bound = response - ts[k].get_wcet() + 1; |
| 63 | mpz_class tmp; | 63 | integral_t tmp; |
| 64 | 64 | ||
| 65 | for (unsigned int i = 0; i < ts.get_task_count(); i++) | 65 | for (unsigned int i = 0; i < ts.get_task_count(); i++) |
| 66 | if (k != i) | 66 | if (k != i) |
diff --git a/native/src/sharedres.cpp b/native/src/sharedres.cpp index 7b61fc3..a691ef9 100644 --- a/native/src/sharedres.cpp +++ b/native/src/sharedres.cpp | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include "sharedres.h" | 7 | #include "sharedres.h" |
| 8 | #include "res_io.h" | 8 | #include "res_io.h" |
| 9 | 9 | ||
| 10 | #include <gmpxx.h> | 10 | #include "time-types.h" |
| 11 | #include "math-helper.h" | 11 | #include "math-helper.h" |
| 12 | 12 | ||
| 13 | #include "stl-helper.h" | 13 | #include "stl-helper.h" |
diff --git a/native/src/tasks.cpp b/native/src/tasks.cpp index 9875b65..1d784bf 100644 --- a/native/src/tasks.cpp +++ b/native/src/tasks.cpp | |||
| @@ -37,14 +37,14 @@ bool Task::is_feasible() const | |||
| 37 | && get_wcet() > 0; | 37 | && get_wcet() > 0; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | void Task::get_utilization(mpq_class &util) const | 40 | void Task::get_utilization(fractional_t &util) const |
| 41 | { | 41 | { |
| 42 | // assumes period != 0 | 42 | // assumes period != 0 |
| 43 | util = get_wcet(); | 43 | util = get_wcet(); |
| 44 | util /= get_period(); | 44 | util /= get_period(); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void Task::get_density(mpq_class &density) const | 47 | void Task::get_density(fractional_t &density) const |
| 48 | { | 48 | { |
| 49 | // assumes deadline != 0 | 49 | // assumes deadline != 0 |
| 50 | density = get_wcet(); | 50 | density = get_wcet(); |
| @@ -95,9 +95,9 @@ bool TaskSet::has_only_feasible_tasks() const | |||
| 95 | FORALL(i, tasks[i].is_feasible()); | 95 | FORALL(i, tasks[i].is_feasible()); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | void TaskSet::get_utilization(mpq_class &util) const | 98 | void TaskSet::get_utilization(fractional_t &util) const |
| 99 | { | 99 | { |
| 100 | mpq_class tmp; | 100 | fractional_t tmp; |
| 101 | util = 0; | 101 | util = 0; |
| 102 | for (unsigned int i = 0; i < tasks.size(); i++) | 102 | for (unsigned int i = 0; i < tasks.size(); i++) |
| 103 | { | 103 | { |
| @@ -106,9 +106,9 @@ void TaskSet::get_utilization(mpq_class &util) const | |||
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | void TaskSet::get_density(mpq_class &density) const | 109 | void TaskSet::get_density(fractional_t &density) const |
| 110 | { | 110 | { |
| 111 | mpq_class tmp; | 111 | fractional_t tmp; |
| 112 | density = 0; | 112 | density = 0; |
| 113 | for (unsigned int i = 0; i < tasks.size(); i++) | 113 | for (unsigned int i = 0; i < tasks.size(); i++) |
| 114 | { | 114 | { |
| @@ -117,9 +117,9 @@ void TaskSet::get_density(mpq_class &density) const | |||
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | void TaskSet::get_max_density(mpq_class &max_density) const | 120 | void TaskSet::get_max_density(fractional_t &max_density) const |
| 121 | { | 121 | { |
| 122 | mpq_class tmp; | 122 | fractional_t tmp; |
| 123 | max_density = 0; | 123 | max_density = 0; |
| 124 | 124 | ||
| 125 | for (unsigned int i = 0; i < tasks.size(); i++) | 125 | for (unsigned int i = 0; i < tasks.size(); i++) |
| @@ -131,17 +131,17 @@ void TaskSet::get_max_density(mpq_class &max_density) const | |||
| 131 | 131 | ||
| 132 | bool TaskSet::is_not_overutilized(unsigned int num_processors) const | 132 | bool TaskSet::is_not_overutilized(unsigned int num_processors) const |
| 133 | { | 133 | { |
| 134 | mpq_class util; | 134 | fractional_t util; |
| 135 | get_utilization(util); | 135 | get_utilization(util); |
| 136 | return util <= num_processors; | 136 | return util <= num_processors; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | // Lemma 7 in FBB:06. | 139 | // Lemma 7 in FBB:06. |
| 140 | unsigned long TaskSet::k_for_epsilon(unsigned int idx, | 140 | unsigned long TaskSet::k_for_epsilon(unsigned int idx, |
| 141 | const mpq_class &epsilon) const | 141 | const fractional_t &epsilon) const |
| 142 | { | 142 | { |
| 143 | mpq_class bound; | 143 | fractional_t bound; |
| 144 | mpq_class dp_ratio(tasks[idx].get_deadline(), | 144 | fractional_t dp_ratio(tasks[idx].get_deadline(), |
| 145 | tasks[idx].get_period()); | 145 | tasks[idx].get_period()); |
| 146 | 146 | ||
| 147 | tasks[idx].get_utilization(bound); | 147 | tasks[idx].get_utilization(bound); |
| @@ -152,9 +152,9 @@ unsigned long TaskSet::k_for_epsilon(unsigned int idx, | |||
| 152 | return (unsigned long) ceil(std::max(0.0, bound.get_d())); | 152 | return (unsigned long) ceil(std::max(0.0, bound.get_d())); |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | void TaskSet::approx_load(mpq_class &load, const mpq_class &epsilon) const | 155 | void TaskSet::approx_load(fractional_t &load, const fractional_t &epsilon) const |
| 156 | { | 156 | { |
| 157 | mpq_class density; | 157 | fractional_t density; |
| 158 | 158 | ||
| 159 | get_density(density); | 159 | get_density(density); |
| 160 | get_utilization(load); | 160 | get_utilization(load); |
| @@ -177,13 +177,13 @@ void TaskSet::approx_load(mpq_class &load, const mpq_class &epsilon) const | |||
| 177 | 177 | ||
| 178 | std::cout << "total_times = " << total_times << std::endl; | 178 | std::cout << "total_times = " << total_times << std::endl; |
| 179 | 179 | ||
| 180 | std::vector<mpz_class> times; | 180 | std::vector<integral_t> times; |
| 181 | times.reserve(total_times); | 181 | times.reserve(total_times); |
| 182 | 182 | ||
| 183 | // determine all test points | 183 | // determine all test points |
| 184 | for (unsigned int i = 0; i < tasks.size(); i++) | 184 | for (unsigned int i = 0; i < tasks.size(); i++) |
| 185 | { | 185 | { |
| 186 | mpz_class time = tasks[i].get_deadline(); | 186 | integral_t time = tasks[i].get_deadline(); |
| 187 | 187 | ||
| 188 | for (unsigned long j = 0; j <= k[i]; j++) | 188 | for (unsigned long j = 0; j <= k[i]; j++) |
| 189 | { | 189 | { |
| @@ -196,15 +196,15 @@ void TaskSet::approx_load(mpq_class &load, const mpq_class &epsilon) const | |||
| 196 | std::sort(times.begin(), times.end()); | 196 | std::sort(times.begin(), times.end()); |
| 197 | 197 | ||
| 198 | // iterate through test points | 198 | // iterate through test points |
| 199 | mpz_class last = 0; | 199 | integral_t last = 0; |
| 200 | 200 | ||
| 201 | for (unsigned int t = 0; t < total_times; t++) | 201 | for (unsigned int t = 0; t < total_times; t++) |
| 202 | { | 202 | { |
| 203 | // avoid redundant check | 203 | // avoid redundant check |
| 204 | if (times[t] > last) | 204 | if (times[t] > last) |
| 205 | { | 205 | { |
| 206 | mpq_class load_at_point = 0; | 206 | fractional_t load_at_point = 0; |
| 207 | mpq_class tmp; | 207 | fractional_t tmp; |
| 208 | 208 | ||
| 209 | // compute approximate load at point | 209 | // compute approximate load at point |
| 210 | for (unsigned int i = 0; i < tasks.size(); i++) | 210 | for (unsigned int i = 0; i < tasks.size(); i++) |
diff --git a/native/src/testmain.cpp b/native/src/testmain.cpp index eeeb96b..7401491 100644 --- a/native/src/testmain.cpp +++ b/native/src/testmain.cpp | |||
| @@ -499,7 +499,7 @@ int xxxmain(int argc, char** argv) | |||
| 499 | { | 499 | { |
| 500 | cout << "GMP C++ test." << endl; | 500 | cout << "GMP C++ test." << endl; |
| 501 | 501 | ||
| 502 | mpz_class a, b; | 502 | integral_t a, b; |
| 503 | 503 | ||
| 504 | a = "123123123123"; | 504 | a = "123123123123"; |
| 505 | b = "456456456456"; | 505 | b = "456456456456"; |
| @@ -508,12 +508,12 @@ int xxxmain(int argc, char** argv) | |||
| 508 | cout << "b : " << b << endl; | 508 | cout << "b : " << b << endl; |
| 509 | cout << "a*b*10: " << a * b * 10 << endl; | 509 | cout << "a*b*10: " << a * b * 10 << endl; |
| 510 | 510 | ||
| 511 | mpq_class q = a; | 511 | fractional_t q = a; |
| 512 | 512 | ||
| 513 | q /= b; | 513 | q /= b; |
| 514 | cout << "a/b :" << q << endl; | 514 | cout << "a/b :" << q << endl; |
| 515 | 515 | ||
| 516 | mpz_class fact; | 516 | integral_t fact; |
| 517 | fact = 1; | 517 | fact = 1; |
| 518 | for (int n = 2; n < 101; n++) { | 518 | for (int n = 2; n < 101; n++) { |
| 519 | fact *= n; | 519 | fact *= n; |
| @@ -529,7 +529,7 @@ int xxxmain(int argc, char** argv) | |||
| 529 | << " deadline: " << t.get_deadline() << endl; | 529 | << " deadline: " << t.get_deadline() << endl; |
| 530 | 530 | ||
| 531 | 531 | ||
| 532 | mpq_class lambda, bound; | 532 | fractional_t lambda, bound; |
| 533 | unsigned int m = 10; | 533 | unsigned int m = 10; |
| 534 | 534 | ||
| 535 | lambda = 3; | 535 | lambda = 3; |
| @@ -654,8 +654,8 @@ int yymain(int argc, char** argv) | |||
| 654 | 654 | ||
| 655 | int main4(int argc, char** argv) | 655 | int main4(int argc, char** argv) |
| 656 | { | 656 | { |
| 657 | mpq_class a, b; | 657 | fractional_t a, b; |
| 658 | mpz_class c; | 658 | integral_t c; |
| 659 | 659 | ||
| 660 | a = 20; | 660 | a = 20; |
| 661 | a /= 3; | 661 | a /= 3; |
| @@ -668,7 +668,7 @@ int main4(int argc, char** argv) | |||
| 668 | 668 | ||
| 669 | cout << c << endl; | 669 | cout << c << endl; |
| 670 | 670 | ||
| 671 | mpq_truncate(b); | 671 | truncate_fraction(b); |
| 672 | cout << b << endl; | 672 | cout << b << endl; |
| 673 | 673 | ||
| 674 | return 0; | 674 | return 0; |
