From da7a2586be45bc784480c440fd8d627a796df671 Mon Sep 17 00:00:00 2001 From: Jeremy Erickson Date: Sat, 26 May 2012 17:55:16 -0400 Subject: Split factor support --- bin/rt_launch.c | 21 +++++++++++++-------- bin/rtspin.c | 28 +++++++++++++++++----------- include/litmus.h | 13 +++++++------ src/litmus.c | 7 ++++--- src/task.c | 11 +++++++---- 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/bin/rt_launch.c b/bin/rt_launch.c index 3863031..2d195bd 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c @@ -29,9 +29,10 @@ int launch(void *task_info_p) { } void usage(char *error) { - fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-p cpu][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n" + fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-n split][-p cpu][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n" "\t-w\tSynchronous release\n" "\t-v\tVerbose\n" + "\t-n\tSplit factor\n" "\t-p\tcpu (or initial cpu)\n" "\t-c\tClass\n" "\twcet, period in ms\n" @@ -41,7 +42,7 @@ void usage(char *error) { } -#define OPTSTR "p:c:vw" +#define OPTSTR "p:c:vwn:" int main(int argc, char** argv) { @@ -49,6 +50,7 @@ int main(int argc, char** argv) lt_t wcet; lt_t period; int migrate = 0; + int split = 1; int cpu = 0; int opt; int verbose = 0; @@ -64,6 +66,9 @@ int main(int argc, char** argv) case 'v': verbose = 1; break; + case 'n': + split = atoi(optarg); + break; case 'p': cpu = atoi(optarg); migrate = 1; @@ -87,27 +92,27 @@ int main(int argc, char** argv) signal(SIGUSR1, SIG_IGN); if (argc - optind < 3) - usage("Arguments missing."); + usage("Arguments missing."); wcet = ms2lt(atoi(argv[optind + 0])); period = ms2lt(atoi(argv[optind + 1])); if (wcet <= 0) usage("The worst-case execution time must be a " - "positive number."); + "positive number."); if (period <= 0) usage("The period must be a positive number."); if (wcet > period) { usage("The worst-case execution time must not " - "exceed the period."); + "exceed the period."); } info.exec_path = argv[optind + 2]; - info.argv = argv + optind + 2; - info.wait = wait; + info.argv = argv + optind + 2; + info.wait = wait; if (migrate) { ret = be_migrate_to(cpu); if (ret < 0) bail_out("could not migrate to target partition"); } - ret = __create_rt_task(launch, &info, cpu, wcet, period, class); + ret = __create_rt_task(launch, &info, split, cpu, wcet, period, class); if (ret < 0) diff --git a/bin/rtspin.c b/bin/rtspin.c index ae76941..1d60524 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c @@ -20,7 +20,7 @@ static void usage(char *error) { " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n" " rt_spin -l\n" "\n" - "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n" + "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE] [-n SPLIT]\n" "\n" "WCET and PERIOD are milliseconds, DURATION is seconds.\n"); exit(EXIT_FAILURE); @@ -45,7 +45,7 @@ static void skip_comments(FILE *fstream) } static void get_exec_times(const char *file, const int column, - int *num_jobs, double **exec_times) + int *num_jobs, double **exec_times) { FILE *fstream; int cur_job, cur_col, ch; @@ -142,10 +142,10 @@ static void debug_delay_loop(void) loop_for(delay, 0); end = wctime(); printf("%6.4fs: looped for %10.8fs, delta=%11.8fs, error=%7.4f%%\n", - delay, - end - start, - end - start - delay, - 100 * (end - start - delay) / delay); + delay, + end - start, + end - start - delay, + 100 * (end - start - delay) / delay); } } } @@ -161,7 +161,7 @@ static int job(double exec_time, double program_end) } } -#define OPTSTR "p:c:wlveo:f:s:" +#define OPTSTR "p:c:wlveo:f:s:n:" int main(int argc, char** argv) { @@ -170,6 +170,7 @@ int main(int argc, char** argv) lt_t period; double wcet_ms, period_ms; int migrate = 0; + int split = 1; int cpu = 0; int opt; int wait = 0; @@ -190,6 +191,9 @@ int main(int argc, char** argv) case 'w': wait = 1; break; + case 'n': + split = atoi(optarg); + break; case 'p': cpu = atoi(optarg); migrate = 1; @@ -258,6 +262,8 @@ int main(int argc, char** argv) "positive number."); if (period <= 0) usage("The period must be a positive number."); + if (split <= 0) + usage("The split factor must be a positive number, if specified."); if (!file && wcet > period) { usage("The worst-case execution time must not " "exceed the period."); @@ -274,10 +280,10 @@ int main(int argc, char** argv) bail_out("could not migrate to target partition"); } - ret = sporadic_task_ns(wcet, period, 0, cpu, class, - want_enforcement ? PRECISE_ENFORCEMENT - : NO_ENFORCEMENT, - migrate); + ret = sporadic_task_ns(wcet, period, 0, split, cpu, class, + want_enforcement ? PRECISE_ENFORCEMENT + : NO_ENFORCEMENT, + migrate); if (ret < 0) bail_out("could not setup rt task params"); diff --git a/include/litmus.h b/include/litmus.h index 4c85d28..78fb4f4 100644 --- a/include/litmus.h +++ b/include/litmus.h @@ -31,21 +31,21 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); /* times are given in ms */ int sporadic_task( - lt_t e, lt_t p, lt_t phase, + lt_t e, lt_t p, lt_t phase, int split, int partition, task_class_t cls, budget_policy_t budget_policy, int set_cpu_set); /* times are given in ns */ int sporadic_task_ns( - lt_t e, lt_t p, lt_t phase, + lt_t e, lt_t p, lt_t phase, int split, int cpu, task_class_t cls, budget_policy_t budget_policy, int set_cpu_set); /* budget enforcement off by default in these macros */ #define sporadic_global(e, p) \ - sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) + sporadic_task(e, p, 0, 1, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) #define sporadic_partitioned(e, p, cpu) \ - sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) + sporadic_task(e, p, 0, 1, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) /* file descriptor attached shared objects support */ typedef enum { @@ -79,8 +79,9 @@ void exit_litmus(void); typedef int (*rt_fn_t)(void*); /* These two functions configure the RT task to use enforced exe budgets */ -int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); -int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, +int create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet, + int period); +int __create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet, int period, task_class_t cls); /* per-task modes */ diff --git a/src/litmus.c b/src/litmus.c index d3cc6bb..bb08e87 100644 --- a/src/litmus.c +++ b/src/litmus.c @@ -41,15 +41,15 @@ int be_migrate_to(int target_cpu) return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); } -int sporadic_task(lt_t e, lt_t p, lt_t phase, +int sporadic_task(lt_t e, lt_t p, lt_t phase, int split, int cpu, task_class_t cls, budget_policy_t budget_policy, int set_cpu_set) { return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, - cpu, cls, budget_policy, set_cpu_set); + split, cpu, cls, budget_policy, set_cpu_set); } -int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, +int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, int split, int cpu, task_class_t cls, budget_policy_t budget_policy, int set_cpu_set) { @@ -63,6 +63,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, param.exec_cost = e; param.period = p; + param.split = split; param.cpu = cpu; param.cls = cls; param.phase = phase; diff --git a/src/task.c b/src/task.c index 4d237bd..1d374f4 100644 --- a/src/task.c +++ b/src/task.c @@ -40,10 +40,11 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup, return rt_task; } -int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, - task_class_t class) +int __create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet, + int period, task_class_t class) { struct rt_task params; + params.split = split; params.cpu = cpu; params.period = period; params.exec_cost = wcet; @@ -56,8 +57,10 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, (rt_setup_fn_t) set_rt_task_param, ¶ms); } -int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period) { - return __create_rt_task(rt_prog, arg, cpu, wcet, period, RT_CLASS_HARD); +int create_rt_task(rt_fn_t rt_prog, void *arg, int split, int cpu, int wcet, + int period) { + return __create_rt_task(rt_prog, arg, split, cpu, wcet, period, + RT_CLASS_HARD); } -- cgit v1.2.2