From 005115e1da60fee3ee01d320fe1de4645cc95bfd Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 4 Feb 2008 15:43:26 -0500 Subject: change to nanosecond resolution time accounting --- bin/rt_launch.c | 19 +++++++++++++------ include/litmus.h | 1 + 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) { "\nExamples:" "\n\trt_launch -p 2 10 100 cpu_job" "\n\t => Launch cpu_job a hard real-time task with " - "\n\t period 100 and weight 0.1 on CPU 2.\n" + "\n\t period 100ms and weight 0.1 on CPU 2.\n" "\n\n", error); exit(1); } -#define OPTSTR "p:c:" +#define OPTSTR "p:c:v" + +#define NS_PER_MS 1000000 int main(int argc, char** argv) { @@ -46,11 +48,15 @@ int main(int argc, char** argv) int period; int cpu = 0; int opt; + int verbose = 0; startup_info_t info; task_class_t class = RT_CLASS_HARD; while ((opt = getopt(argc, argv, OPTSTR)) != -1) { switch (opt) { + case 'v': + verbose = 1; + break; case 'p': cpu = atoi(optarg); break; @@ -74,8 +80,8 @@ int main(int argc, char** argv) if (argc - optind < 3) usage("Arguments missing."); - wcet = atoi(argv[optind + 0]); - period = atoi(argv[optind + 1]); + wcet = atoi(argv[optind + 0]) * NS_PER_MS; + period = atoi(argv[optind + 1]) * NS_PER_MS; if (wcet <= 0) usage("The worst-case execution time must be a " "positive number."); @@ -92,8 +98,9 @@ int main(int argc, char** argv) if (ret < 0) { perror("Could not create rt child process"); - return 2; - } + return 2; + } else if (verbose) + printf("%d\n", ret); return 0; } 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); int get_rt_task_param(pid_t pid, struct rt_task* param); /* setup helper */ +/* times are givin in ms */ int sporadic_task(unsigned long exec_cost, unsigned long period, int partition, task_class_t cls); 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) return -1; } +#define NS_PER_MS 1000000 + int sporadic_task(unsigned long e, unsigned long p, int cpu, task_class_t cls) { struct rt_task param; - param.exec_cost = e; - param.period = p; + param.exec_cost = e * NS_PER_MS; + param.period = p * NS_PER_MS; param.cpu = cpu; - param.cls = cls; + param.cls = cls; return set_rt_task_param(gettid(), ¶m); } -- cgit v1.2.2