diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-03-10 18:47:45 -0500 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-03-10 18:47:45 -0500 |
| commit | 4eb2e8fa463990a57f5619b2aedb32c4a98c4ea0 (patch) | |
| tree | 94739316512bc5440aca9ec6012d30e5ea5cef39 | |
| parent | f2381aa53a0656c03f2dd8b9d753d2a84132aafb (diff) | |
Add -v (verbose) switch to rtspin.
Can be used to dump the delay loop that rtspin
is using.
| -rw-r--r-- | bin/rtspin.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c index 89ccbba..aa97745 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
| @@ -38,6 +38,7 @@ void usage(char *error) { | |||
| 38 | #define NUMS 4096 | 38 | #define NUMS 4096 |
| 39 | static int num[NUMS]; | 39 | static int num[NUMS]; |
| 40 | static double loop_length = 1.0; | 40 | static double loop_length = 1.0; |
| 41 | static char* progname; | ||
| 41 | 42 | ||
| 42 | static int loop_once(void) | 43 | static int loop_once(void) |
| 43 | { | 44 | { |
| @@ -100,10 +101,17 @@ static void configure_loop(void) | |||
| 100 | fine_tune(0.1); | 101 | fine_tune(0.1); |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 104 | static void show_loop_length(void) | ||
| 105 | { | ||
| 106 | printf("%s/%d: loop_length=%f (%ldus)\n", | ||
| 107 | progname, getpid(), loop_length, | ||
| 108 | (long) (loop_length * 1000000)); | ||
| 109 | } | ||
| 110 | |||
| 103 | static void debug_delay_loop(void) | 111 | static void debug_delay_loop(void) |
| 104 | { | 112 | { |
| 105 | double start, end, delay; | 113 | double start, end, delay; |
| 106 | printf("loop_length=%f\n", loop_length); | 114 | show_loop_length(); |
| 107 | while (1) { | 115 | while (1) { |
| 108 | for (delay = 0.5; delay > 0.01; delay -= 0.01) { | 116 | for (delay = 0.5; delay > 0.01; delay -= 0.01) { |
| 109 | start = wctime(); | 117 | start = wctime(); |
| @@ -125,7 +133,7 @@ static int job(double exec_time) | |||
| 125 | return 0; | 133 | return 0; |
| 126 | } | 134 | } |
| 127 | 135 | ||
| 128 | #define OPTSTR "p:c:wld:" | 136 | #define OPTSTR "p:c:wld:v" |
| 129 | 137 | ||
| 130 | int main(int argc, char** argv) | 138 | int main(int argc, char** argv) |
| 131 | { | 139 | { |
| @@ -139,9 +147,12 @@ int main(int argc, char** argv) | |||
| 139 | int wait = 0; | 147 | int wait = 0; |
| 140 | int test_loop = 0; | 148 | int test_loop = 0; |
| 141 | int skip_config = 0; | 149 | int skip_config = 0; |
| 150 | int verbose = 0; | ||
| 142 | double duration, start; | 151 | double duration, start; |
| 143 | task_class_t class = RT_CLASS_HARD; | 152 | task_class_t class = RT_CLASS_HARD; |
| 144 | 153 | ||
| 154 | progname = argv[0]; | ||
| 155 | |||
| 145 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 156 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
| 146 | switch (opt) { | 157 | switch (opt) { |
| 147 | case 'w': | 158 | case 'w': |
| @@ -160,9 +171,14 @@ int main(int argc, char** argv) | |||
| 160 | test_loop = 1; | 171 | test_loop = 1; |
| 161 | break; | 172 | break; |
| 162 | case 'd': | 173 | case 'd': |
| 163 | loop_length = atof(optarg) / 1000000; | 174 | /* manually configure delay per loop iteration |
| 175 | * unit: microseconds */ | ||
| 176 | loop_length = atof(optarg) / 1000000; | ||
| 164 | skip_config = 1; | 177 | skip_config = 1; |
| 165 | break; | 178 | break; |
| 179 | case 'v': | ||
| 180 | verbose = 1; | ||
| 181 | break; | ||
| 166 | case ':': | 182 | case ':': |
| 167 | usage("Argument missing."); | 183 | usage("Argument missing."); |
| 168 | break; | 184 | break; |
| @@ -173,7 +189,7 @@ int main(int argc, char** argv) | |||
| 173 | } | 189 | } |
| 174 | } | 190 | } |
| 175 | 191 | ||
| 176 | 192 | ||
| 177 | if (!skip_config) | 193 | if (!skip_config) |
| 178 | configure_loop(); | 194 | configure_loop(); |
| 179 | 195 | ||
| @@ -183,7 +199,7 @@ int main(int argc, char** argv) | |||
| 183 | } | 199 | } |
| 184 | 200 | ||
| 185 | if (argc - optind < 3) | 201 | if (argc - optind < 3) |
| 186 | usage("Arguments missing."); | 202 | usage("Arguments missing."); |
| 187 | wcet_ms = atof(argv[optind + 0]); | 203 | wcet_ms = atof(argv[optind + 0]); |
| 188 | period_ms = atof(argv[optind + 1]); | 204 | period_ms = atof(argv[optind + 1]); |
| 189 | duration = atof(argv[optind + 2]); | 205 | duration = atof(argv[optind + 2]); |
| @@ -206,15 +222,18 @@ int main(int argc, char** argv) | |||
| 206 | } | 222 | } |
| 207 | 223 | ||
| 208 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, migrate); | 224 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, migrate); |
| 209 | 225 | ||
| 210 | if (ret < 0) | 226 | if (ret < 0) |
| 211 | bail_out("could not become rt tasks."); | 227 | bail_out("could not setup rt task params"); |
| 228 | |||
| 229 | if (verbose) | ||
| 230 | show_loop_length(); | ||
| 212 | 231 | ||
| 213 | init_litmus(); | 232 | init_litmus(); |
| 214 | 233 | ||
| 215 | ret = task_mode(LITMUS_RT_TASK); | 234 | ret = task_mode(LITMUS_RT_TASK); |
| 216 | if (ret != 0) | 235 | if (ret != 0) |
| 217 | bail_out("task_mode()"); | 236 | bail_out("could not become RT task"); |
| 218 | 237 | ||
| 219 | if (wait) { | 238 | if (wait) { |
| 220 | ret = wait_for_ts_release(); | 239 | ret = wait_for_ts_release(); |
| @@ -222,7 +241,6 @@ int main(int argc, char** argv) | |||
| 222 | bail_out("wait_for_ts_release()"); | 241 | bail_out("wait_for_ts_release()"); |
| 223 | } | 242 | } |
| 224 | 243 | ||
| 225 | |||
| 226 | start = wctime(); | 244 | start = wctime(); |
| 227 | 245 | ||
| 228 | while (start + duration > wctime()) { | 246 | while (start + duration > wctime()) { |
