diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-01-30 12:26:36 -0500 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-01-30 12:28:28 -0500 |
| commit | 455f8e4ef3fd02d41e2d8ae40918dd22bf7e4f45 (patch) | |
| tree | a5661a04e8192d9bccef3d0431eff7d4538fa814 /bin | |
| parent | c013cd8625b0ebb28f71337109d3fbfdf0a6b621 (diff) | |
Remove old delay loop configuration cruft from rtspin
Using cputime() is much more accurate than the old delay loop
auto-configuration. There is no good reason to keep it around.
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/rtspin.c | 78 |
1 files changed, 9 insertions, 69 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c index 3e22ffe..75e9494 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
| @@ -112,7 +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; | 115 | static char* progname; |
| 117 | 116 | ||
| 118 | static int loop_once(void) | 117 | static int loop_once(void) |
| @@ -125,19 +124,17 @@ static int loop_once(void) | |||
| 125 | 124 | ||
| 126 | static int loop_for(double exec_time, double emergency_exit) | 125 | static int loop_for(double exec_time, double emergency_exit) |
| 127 | { | 126 | { |
| 128 | double t = 0; | 127 | double last_loop = 0, loop_start; |
| 129 | int tmp = 0; | 128 | int tmp = 0; |
| 130 | /* while (t + loop_length < exec_time) { | 129 | |
| 131 | tmp += loop_once(); | ||
| 132 | t += loop_length; | ||
| 133 | } | ||
| 134 | */ | ||
| 135 | double start = cputime(); | 130 | double start = cputime(); |
| 136 | double now = cputime(); | 131 | double now = cputime(); |
| 137 | while (now + loop_length < start + exec_time) { | 132 | |
| 133 | while (now + last_loop < start + exec_time) { | ||
| 134 | loop_start = now; | ||
| 138 | tmp += loop_once(); | 135 | tmp += loop_once(); |
| 139 | t += loop_length; | ||
| 140 | now = cputime(); | 136 | now = cputime(); |
| 137 | last_loop = loop_start - now; | ||
| 141 | if (emergency_exit && wctime() > emergency_exit) { | 138 | if (emergency_exit && wctime() > emergency_exit) { |
| 142 | /* Oops --- this should only be possible if the execution time tracking | 139 | /* Oops --- this should only be possible if the execution time tracking |
| 143 | * is broken in the LITMUS^RT kernel. */ | 140 | * is broken in the LITMUS^RT kernel. */ |
| @@ -150,50 +147,11 @@ static int loop_for(double exec_time, double emergency_exit) | |||
| 150 | return tmp; | 147 | return tmp; |
| 151 | } | 148 | } |
| 152 | 149 | ||
| 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 | 150 | ||
| 193 | static void debug_delay_loop(void) | 151 | static void debug_delay_loop(void) |
| 194 | { | 152 | { |
| 195 | double start, end, delay; | 153 | double start, end, delay; |
| 196 | show_loop_length(); | 154 | |
| 197 | while (1) { | 155 | while (1) { |
| 198 | for (delay = 0.5; delay > 0.01; delay -= 0.01) { | 156 | for (delay = 0.5; delay > 0.01; delay -= 0.01) { |
| 199 | start = wctime(); | 157 | start = wctime(); |
| @@ -219,9 +177,9 @@ static int job(double exec_time, double program_end) | |||
| 219 | } | 177 | } |
| 220 | } | 178 | } |
| 221 | 179 | ||
| 222 | #define OPTSTR "p:c:wld:veo:f:s:" | 180 | #define OPTSTR "p:c:wlveo:f:s:" |
| 223 | 181 | ||
| 224 | int main(int argc, char** argv) | 182 | int main(int argc, char** argv) |
| 225 | { | 183 | { |
| 226 | int ret; | 184 | int ret; |
| 227 | lt_t wcet; | 185 | lt_t wcet; |
| @@ -232,8 +190,6 @@ int main(int argc, char** argv) | |||
| 232 | int opt; | 190 | int opt; |
| 233 | int wait = 0; | 191 | int wait = 0; |
| 234 | int test_loop = 0; | 192 | int test_loop = 0; |
| 235 | int skip_config = 0; | ||
| 236 | int verbose = 0; | ||
| 237 | int column = 1; | 193 | int column = 1; |
| 238 | const char *file = NULL; | 194 | const char *file = NULL; |
| 239 | int want_enforcement = 0; | 195 | int want_enforcement = 0; |
| @@ -265,15 +221,6 @@ int main(int argc, char** argv) | |||
| 265 | case 'l': | 221 | case 'l': |
| 266 | test_loop = 1; | 222 | test_loop = 1; |
| 267 | break; | 223 | 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': | 224 | case 'o': |
| 278 | column = atoi(optarg); | 225 | column = atoi(optarg); |
| 279 | break; | 226 | break; |
| @@ -293,10 +240,6 @@ int main(int argc, char** argv) | |||
| 293 | } | 240 | } |
| 294 | } | 241 | } |
| 295 | 242 | ||
| 296 | |||
| 297 | if (!skip_config) | ||
| 298 | configure_loop(); | ||
| 299 | |||
| 300 | if (test_loop) { | 243 | if (test_loop) { |
| 301 | debug_delay_loop(); | 244 | debug_delay_loop(); |
| 302 | return 0; | 245 | return 0; |
| @@ -354,9 +297,6 @@ int main(int argc, char** argv) | |||
| 354 | if (ret < 0) | 297 | if (ret < 0) |
| 355 | bail_out("could not setup rt task params"); | 298 | bail_out("could not setup rt task params"); |
| 356 | 299 | ||
| 357 | if (verbose) | ||
| 358 | show_loop_length(); | ||
| 359 | |||
| 360 | init_litmus(); | 300 | init_litmus(); |
| 361 | 301 | ||
| 362 | ret = task_mode(LITMUS_RT_TASK); | 302 | ret = task_mode(LITMUS_RT_TASK); |
