From dbf6cfe8cb089bd6921b3b9811e175fd496c9d0f Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 24 Jun 2010 21:08:02 -0400 Subject: [NPS-F] Add rt_launch version for NPS-F algo --- SConstruct | 3 +- bin/rt_launch_npsf.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/litmus.h | 2 + src/task.c | 17 ++++++++ 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 bin/rt_launch_npsf.c diff --git a/SConstruct b/SConstruct index 0888e90..657a92f 100644 --- a/SConstruct +++ b/SConstruct @@ -209,9 +209,10 @@ mtrt.Program('base_mt_task', 'bin/base_mt_task.c') rt.Program('rt_launch', ['bin/rt_launch.c', 'bin/common.c']) rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c']) rt.Program('rtspin_edffm', ['bin/rtspin_edffm.c', 'bin/common.c']) +rt.Program('rt_launch_edffm', ['bin/rt_launch_edffm.c', 'bin/common.c']) rt.Program('rtspin_npsf', ['bin/rtspin_npsf.c', 'bin/common.c']) rt.Program('npsf_add_server', ['bin/npsf_add_server.c', 'bin/common.c']) -rt.Program('rt_launch_edffm', ['bin/rt_launch_edffm.c', 'bin/common.c']) +rt.Program('rt_launch_npsf', ['bin/rt_launch_npsf.c', 'bin/common.c']) rt.Program('release_ts', 'bin/release_ts.c') rtm.Program('measure_syscall', 'bin/null_call.c') diff --git a/bin/rt_launch_npsf.c b/bin/rt_launch_npsf.c new file mode 100644 index 0000000..97ad361 --- /dev/null +++ b/bin/rt_launch_npsf.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include + +#include "litmus.h" +#include "common.h" + +typedef struct { + int wait; + char * exec_path; + char ** argv; +} startup_info_t; + + +int launch(void *task_info_p) { + startup_info_t *info = (startup_info_t*) task_info_p; + int ret; + if (info->wait) { + ret = wait_for_ts_release(); + if (ret != 0) + perror("wait_for_ts_release()"); + } + ret = execvp(info->exec_path, info->argv); + perror("execv failed"); + return ret; +} + +void usage(char *error) { + fprintf(stderr, "%s\nUsage: rt_launch [-w][-v] wcet period cpu npsf-id program [arg1 arg2 ...]\n" + "\t-w\tSynchronous release\n" + "\t-v\tVerbose\n" + "\twcet, period in ms\n" + "\tprogram to be launched\n", + error); + exit(1); +} + + +#define OPTSTR "vw" + +int main(int argc, char** argv) +{ + int ret; + lt_t wcet; + lt_t period; + int migrate = 0; + int cpu = 0; + int npsf_id; + int opt; + int verbose = 0; + int wait = 0; + startup_info_t info; + + while ((opt = getopt(argc, argv, OPTSTR)) != -1) { + switch (opt) { + case 'w': + wait = 1; + break; + case 'v': + verbose = 1; + break; + case ':': + usage("Argument missing."); + break; + case '?': + default: + usage("Bad argument."); + break; + } + } + + signal(SIGUSR1, SIG_IGN); + + if (argc - optind < 5) + usage("Arguments missing."); + wcet = ms2lt(atoi(argv[optind + 0])); + period = ms2lt(atoi(argv[optind + 1])); + cpu = atoi(argv[optind + 2]); + migrate = 1; + npsf_id = atoi(argv[optind + 3]); + if (wcet <= 0) + usage("The worst-case execution time must be a " + "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."); + } + info.exec_path = argv[optind + 4]; + info.argv = argv + optind + 4; + 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_npsf(launch, &info, cpu, wcet, period, npsf_id, RT_CLASS_HARD); + + + if (ret < 0) + bail_out("could not create rt child process"); + else if (verbose) + printf("%d\n", ret); + + return 0; +} diff --git a/include/litmus.h b/include/litmus.h index d7f7b99..9d2339f 100644 --- a/include/litmus.h +++ b/include/litmus.h @@ -98,6 +98,8 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, lt_t *frac1, lt_t *frac2, int cpu1, int cpu2, task_class_t class); +int __create_rt_task_npsf(rt_fn_t rt_prog, void *arg, int cpu, int wcet, + int period, task_class_t class, int npsf_id); /* per-task modes */ enum rt_task_mode_t { diff --git a/src/task.c b/src/task.c index 905ab9c..c88c16b 100644 --- a/src/task.c +++ b/src/task.c @@ -69,6 +69,23 @@ int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, (rt_setup_fn_t) set_rt_task_param, ¶ms); } +int __create_rt_task_npsf(rt_fn_t rt_prog, void *arg, int cpu, int wcet, + int period, task_class_t class, int npsf_id) +{ + struct rt_task params; + params.cpu = cpu; + params.period = period; + params.exec_cost = wcet; + params.cls = class; + params.phase = 0; + /* enforce budget for tasks that might not use sleep_next_period() */ + params.budget_policy = QUANTUM_ENFORCEMENT; + params.npsf_id = npsf_id; + + return __launch_rt_task(rt_prog, arg, + (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, task_class_t class) { -- cgit v1.2.2