diff options
| -rw-r--r-- | bin/rtspin.c | 100 |
1 files changed, 2 insertions, 98 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c index 3e22ffe..01855ab 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
| @@ -112,8 +112,6 @@ static void get_exec_times(const char *file, const int column, | |||
| 112 | 112 | ||
| 113 | #define NUMS 4096 | 113 | #define NUMS 4096 |
| 114 | static int num[NUMS]; | 114 | static int num[NUMS]; |
| 115 | static double loop_length = 1.0; | ||
| 116 | static char* progname; | ||
| 117 | 115 | ||
| 118 | static int loop_once(void) | 116 | static int loop_once(void) |
| 119 | { | 117 | { |
| @@ -125,18 +123,11 @@ static int loop_once(void) | |||
| 125 | 123 | ||
| 126 | static int loop_for(double exec_time, double emergency_exit) | 124 | static int loop_for(double exec_time, double emergency_exit) |
| 127 | { | 125 | { |
| 128 | double t = 0; | ||
| 129 | int tmp = 0; | 126 | int tmp = 0; |
| 130 | /* while (t + loop_length < exec_time) { | ||
| 131 | tmp += loop_once(); | ||
| 132 | t += loop_length; | ||
| 133 | } | ||
| 134 | */ | ||
| 135 | double start = cputime(); | 127 | double start = cputime(); |
| 136 | double now = cputime(); | 128 | double now = cputime(); |
| 137 | while (now + loop_length < start + exec_time) { | 129 | while (now < start + exec_time) { |
| 138 | tmp += loop_once(); | 130 | tmp += loop_once(); |
| 139 | t += loop_length; | ||
| 140 | now = cputime(); | 131 | now = cputime(); |
| 141 | if (emergency_exit && wctime() > emergency_exit) { | 132 | if (emergency_exit && wctime() > emergency_exit) { |
| 142 | /* Oops --- this should only be possible if the execution time tracking | 133 | /* Oops --- this should only be possible if the execution time tracking |
| @@ -150,64 +141,6 @@ static int loop_for(double exec_time, double emergency_exit) | |||
| 150 | return tmp; | 141 | return tmp; |
| 151 | } | 142 | } |
| 152 | 143 | ||
| 153 | static void fine_tune(double interval) | ||
| 154 | { | ||
| 155 | double start, end, delta; | ||
| 156 | |||
| 157 | start = wctime(); | ||
| 158 | loop_for(interval, 0); | ||
| 159 | end = wctime(); | ||
| 160 | delta = (end - start - interval) / interval; | ||
| 161 | if (delta != 0) | ||
| 162 | loop_length = loop_length / (1 - delta); | ||
| 163 | } | ||
| 164 | |||
| 165 | static void configure_loop(void) | ||
| 166 | { | ||
| 167 | double start; | ||
| 168 | |||
| 169 | /* prime cache */ | ||
| 170 | loop_once(); | ||
| 171 | loop_once(); | ||
| 172 | loop_once(); | ||
| 173 | |||
| 174 | /* measure */ | ||
| 175 | start = wctime(); | ||
| 176 | loop_once(); /* hope we didn't get preempted */ | ||
| 177 | loop_length = wctime(); | ||
| 178 | loop_length -= start; | ||
| 179 | |||
| 180 | /* fine tune */ | ||
| 181 | fine_tune(0.1); | ||
| 182 | fine_tune(0.1); | ||
| 183 | fine_tune(0.1); | ||
| 184 | } | ||
| 185 | |||
| 186 | static void show_loop_length(void) | ||
| 187 | { | ||
| 188 | printf("%s/%d: loop_length=%f (%ldus)\n", | ||
| 189 | progname, getpid(), loop_length, | ||
| 190 | (long) (loop_length * 1000000)); | ||
| 191 | } | ||
| 192 | |||
| 193 | static void debug_delay_loop(void) | ||
| 194 | { | ||
| 195 | double start, end, delay; | ||
| 196 | show_loop_length(); | ||
| 197 | while (1) { | ||
| 198 | for (delay = 0.5; delay > 0.01; delay -= 0.01) { | ||
| 199 | start = wctime(); | ||
| 200 | loop_for(delay, 0); | ||
| 201 | end = wctime(); | ||
| 202 | printf("%6.4fs: looped for %10.8fs, delta=%11.8fs, error=%7.4f%%\n", | ||
| 203 | delay, | ||
| 204 | end - start, | ||
| 205 | end - start - delay, | ||
| 206 | 100 * (end - start - delay) / delay); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | } | ||
| 210 | |||
| 211 | static int job(double exec_time, double program_end) | 144 | static int job(double exec_time, double program_end) |
| 212 | { | 145 | { |
| 213 | if (wctime() > program_end) | 146 | if (wctime() > program_end) |
| @@ -221,7 +154,7 @@ static int job(double exec_time, double program_end) | |||
| 221 | 154 | ||
| 222 | #define OPTSTR "p:c:wld:veo:f:s:" | 155 | #define OPTSTR "p:c:wld:veo:f:s:" |
| 223 | 156 | ||
| 224 | int main(int argc, char** argv) | 157 | int main(int argc, char** argv) |
| 225 | { | 158 | { |
| 226 | int ret; | 159 | int ret; |
| 227 | lt_t wcet; | 160 | lt_t wcet; |
| @@ -231,9 +164,6 @@ int main(int argc, char** argv) | |||
| 231 | int cpu = 0; | 164 | int cpu = 0; |
| 232 | int opt; | 165 | int opt; |
| 233 | int wait = 0; | 166 | int wait = 0; |
| 234 | int test_loop = 0; | ||
| 235 | int skip_config = 0; | ||
| 236 | int verbose = 0; | ||
| 237 | int column = 1; | 167 | int column = 1; |
| 238 | const char *file = NULL; | 168 | const char *file = NULL; |
| 239 | int want_enforcement = 0; | 169 | int want_enforcement = 0; |
| @@ -243,8 +173,6 @@ int main(int argc, char** argv) | |||
| 243 | task_class_t class = RT_CLASS_HARD; | 173 | task_class_t class = RT_CLASS_HARD; |
| 244 | int cur_job, num_jobs; | 174 | int cur_job, num_jobs; |
| 245 | 175 | ||
| 246 | progname = argv[0]; | ||
| 247 | |||
| 248 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 176 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
| 249 | switch (opt) { | 177 | switch (opt) { |
| 250 | case 'w': | 178 | case 'w': |
| @@ -262,18 +190,6 @@ int main(int argc, char** argv) | |||
| 262 | case 'e': | 190 | case 'e': |
| 263 | want_enforcement = 1; | 191 | want_enforcement = 1; |
| 264 | break; | 192 | break; |
| 265 | case 'l': | ||
| 266 | test_loop = 1; | ||
| 267 | break; | ||
| 268 | case 'd': | ||
| 269 | /* manually configure delay per loop iteration | ||
| 270 | * unit: microseconds */ | ||
| 271 | loop_length = atof(optarg) / 1000000; | ||
| 272 | skip_config = 1; | ||
| 273 | break; | ||
| 274 | case 'v': | ||
| 275 | verbose = 1; | ||
| 276 | break; | ||
| 277 | case 'o': | 193 | case 'o': |
| 278 | column = atoi(optarg); | 194 | column = atoi(optarg); |
| 279 | break; | 195 | break; |
| @@ -293,15 +209,6 @@ int main(int argc, char** argv) | |||
| 293 | } | 209 | } |
| 294 | } | 210 | } |
| 295 | 211 | ||
| 296 | |||
| 297 | if (!skip_config) | ||
| 298 | configure_loop(); | ||
| 299 | |||
| 300 | if (test_loop) { | ||
| 301 | debug_delay_loop(); | ||
| 302 | return 0; | ||
| 303 | } | ||
| 304 | |||
| 305 | if (file) { | 212 | if (file) { |
| 306 | get_exec_times(file, column, &num_jobs, &exec_times); | 213 | get_exec_times(file, column, &num_jobs, &exec_times); |
| 307 | 214 | ||
| @@ -354,9 +261,6 @@ int main(int argc, char** argv) | |||
| 354 | if (ret < 0) | 261 | if (ret < 0) |
| 355 | bail_out("could not setup rt task params"); | 262 | bail_out("could not setup rt task params"); |
| 356 | 263 | ||
| 357 | if (verbose) | ||
| 358 | show_loop_length(); | ||
| 359 | |||
| 360 | init_litmus(); | 264 | init_litmus(); |
| 361 | 265 | ||
| 362 | ret = task_mode(LITMUS_RT_TASK); | 266 | ret = task_mode(LITMUS_RT_TASK); |
