diff options
| -rw-r--r-- | bin/rt_launch.c | 19 | ||||
| -rw-r--r-- | include/litmus.h | 1 | ||||
| -rw-r--r-- | src/litmus.c | 8 |
3 files changed, 19 insertions, 9 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index 186c0fa..94d2dec 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c | |||
| @@ -30,14 +30,16 @@ void usage(char *error) { | |||
| 30 | "\nExamples:" | 30 | "\nExamples:" |
| 31 | "\n\trt_launch -p 2 10 100 cpu_job" | 31 | "\n\trt_launch -p 2 10 100 cpu_job" |
| 32 | "\n\t => Launch cpu_job a hard real-time task with " | 32 | "\n\t => Launch cpu_job a hard real-time task with " |
| 33 | "\n\t period 100 and weight 0.1 on CPU 2.\n" | 33 | "\n\t period 100ms and weight 0.1 on CPU 2.\n" |
| 34 | "\n\n", | 34 | "\n\n", |
| 35 | error); | 35 | error); |
| 36 | exit(1); | 36 | exit(1); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | #define OPTSTR "p:c:" | 40 | #define OPTSTR "p:c:v" |
| 41 | |||
| 42 | #define NS_PER_MS 1000000 | ||
| 41 | 43 | ||
| 42 | int main(int argc, char** argv) | 44 | int main(int argc, char** argv) |
| 43 | { | 45 | { |
| @@ -46,11 +48,15 @@ int main(int argc, char** argv) | |||
| 46 | int period; | 48 | int period; |
| 47 | int cpu = 0; | 49 | int cpu = 0; |
| 48 | int opt; | 50 | int opt; |
| 51 | int verbose = 0; | ||
| 49 | startup_info_t info; | 52 | startup_info_t info; |
| 50 | task_class_t class = RT_CLASS_HARD; | 53 | task_class_t class = RT_CLASS_HARD; |
| 51 | 54 | ||
| 52 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 55 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
| 53 | switch (opt) { | 56 | switch (opt) { |
| 57 | case 'v': | ||
| 58 | verbose = 1; | ||
| 59 | break; | ||
| 54 | case 'p': | 60 | case 'p': |
| 55 | cpu = atoi(optarg); | 61 | cpu = atoi(optarg); |
| 56 | break; | 62 | break; |
| @@ -74,8 +80,8 @@ int main(int argc, char** argv) | |||
| 74 | 80 | ||
| 75 | if (argc - optind < 3) | 81 | if (argc - optind < 3) |
| 76 | usage("Arguments missing."); | 82 | usage("Arguments missing."); |
| 77 | wcet = atoi(argv[optind + 0]); | 83 | wcet = atoi(argv[optind + 0]) * NS_PER_MS; |
| 78 | period = atoi(argv[optind + 1]); | 84 | period = atoi(argv[optind + 1]) * NS_PER_MS; |
| 79 | if (wcet <= 0) | 85 | if (wcet <= 0) |
| 80 | usage("The worst-case execution time must be a " | 86 | usage("The worst-case execution time must be a " |
| 81 | "positive number."); | 87 | "positive number."); |
| @@ -92,8 +98,9 @@ int main(int argc, char** argv) | |||
| 92 | 98 | ||
| 93 | if (ret < 0) { | 99 | if (ret < 0) { |
| 94 | perror("Could not create rt child process"); | 100 | perror("Could not create rt child process"); |
| 95 | return 2; | 101 | return 2; |
| 96 | } | 102 | } else if (verbose) |
| 103 | printf("%d\n", ret); | ||
| 97 | 104 | ||
| 98 | return 0; | 105 | return 0; |
| 99 | } | 106 | } |
diff --git a/include/litmus.h b/include/litmus.h index cf39f80..b10abff 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
| @@ -13,6 +13,7 @@ int set_rt_task_param(pid_t pid, struct rt_task* param); | |||
| 13 | int get_rt_task_param(pid_t pid, struct rt_task* param); | 13 | int get_rt_task_param(pid_t pid, struct rt_task* param); |
| 14 | 14 | ||
| 15 | /* setup helper */ | 15 | /* setup helper */ |
| 16 | /* times are givin in ms */ | ||
| 16 | int sporadic_task(unsigned long exec_cost, unsigned long period, | 17 | int sporadic_task(unsigned long exec_cost, unsigned long period, |
| 17 | int partition, task_class_t cls); | 18 | int partition, task_class_t cls); |
| 18 | 19 | ||
diff --git a/src/litmus.c b/src/litmus.c index 6503088..4666471 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
| @@ -27,14 +27,16 @@ task_class_t str2class(const char* str) | |||
| 27 | return -1; | 27 | return -1; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | #define NS_PER_MS 1000000 | ||
| 31 | |||
| 30 | int sporadic_task(unsigned long e, unsigned long p, | 32 | int sporadic_task(unsigned long e, unsigned long p, |
| 31 | int cpu, task_class_t cls) | 33 | int cpu, task_class_t cls) |
| 32 | { | 34 | { |
| 33 | struct rt_task param; | 35 | struct rt_task param; |
| 34 | param.exec_cost = e; | 36 | param.exec_cost = e * NS_PER_MS; |
| 35 | param.period = p; | 37 | param.period = p * NS_PER_MS; |
| 36 | param.cpu = cpu; | 38 | param.cpu = cpu; |
| 37 | param.cls = cls; | 39 | param.cls = cls; |
| 38 | return set_rt_task_param(gettid(), ¶m); | 40 | return set_rt_task_param(gettid(), ¶m); |
| 39 | } | 41 | } |
| 40 | 42 | ||
