diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2013-03-21 18:54:19 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2013-03-21 18:54:19 -0400 |
commit | 6d5c9b4a6c56bd109b0563cecae447d6480aec66 (patch) | |
tree | ecb9f005355f9cb53b7f968cc79e2d4f4edd6353 | |
parent | 020dc974933f4e9459f699625a138c33811eadf6 (diff) |
Change create_rt_task() to task rt_task parameter.
This updates create_rt_task() to take an rt_task parameter
instead of a number of task parameters. This probably
should have been a part of patches recent patches that revised
the sproadic_*() macros.
-rw-r--r-- | bin/rt_launch.c | 23 | ||||
-rw-r--r-- | include/litmus.h | 10 | ||||
-rw-r--r-- | src/task.c | 29 |
3 files changed, 29 insertions, 33 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index f5de40c..805e20b 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c | |||
@@ -42,7 +42,7 @@ void usage(char *error) { | |||
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | #define OPTSTR "p:z:c:vwq:" | 45 | #define OPTSTR "p:z:c:vwq:t" |
46 | 46 | ||
47 | int main(int argc, char** argv) | 47 | int main(int argc, char** argv) |
48 | { | 48 | { |
@@ -58,6 +58,8 @@ int main(int argc, char** argv) | |||
58 | startup_info_t info; | 58 | startup_info_t info; |
59 | task_class_t cls = RT_CLASS_HARD; | 59 | task_class_t cls = RT_CLASS_HARD; |
60 | unsigned int priority = LITMUS_LOWEST_PRIORITY; | 60 | unsigned int priority = LITMUS_LOWEST_PRIORITY; |
61 | budget_policy_t budget_pol = QUANTUM_ENFORCEMENT; | ||
62 | struct rt_task param; | ||
61 | 63 | ||
62 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 64 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
63 | switch (opt) { | 65 | switch (opt) { |
@@ -84,7 +86,10 @@ int main(int argc, char** argv) | |||
84 | if (cls == -1) | 86 | if (cls == -1) |
85 | usage("Unknown task class."); | 87 | usage("Unknown task class."); |
86 | break; | 88 | break; |
87 | 89 | case 't': | |
90 | /* use an hrtimer for budget enforcement */ | ||
91 | budget_pol = PRECISE_ENFORCEMENT; | ||
92 | break; | ||
88 | case ':': | 93 | case ':': |
89 | usage("Argument missing."); | 94 | usage("Argument missing."); |
90 | break; | 95 | break; |
@@ -118,8 +123,18 @@ int main(int argc, char** argv) | |||
118 | if (ret < 0) | 123 | if (ret < 0) |
119 | bail_out("could not migrate to target partition or cluster"); | 124 | bail_out("could not migrate to target partition or cluster"); |
120 | } | 125 | } |
121 | ret = __create_rt_task(launch, &info, cluster, cluster_size, wcet, period, | 126 | |
122 | priority, cls); | 127 | init_rt_task_param(¶m); |
128 | param.exec_cost = wcet; | ||
129 | param.period = period; | ||
130 | param.priority = priority; | ||
131 | param.cls = cls; | ||
132 | param.budget_policy = budget_pol; | ||
133 | |||
134 | if (migrate) | ||
135 | param.cpu = cluster_to_first_cpu(cluster, cluster_size); | ||
136 | |||
137 | ret = create_rt_task(launch, &info, ¶m); | ||
123 | 138 | ||
124 | if (ret < 0) | 139 | if (ret < 0) |
125 | bail_out("could not create rt child process"); | 140 | bail_out("could not create rt child process"); |
diff --git a/include/litmus.h b/include/litmus.h index accdbaa..d3b89cf 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -117,14 +117,8 @@ void exit_litmus(void); | |||
117 | /* A real-time program. */ | 117 | /* A real-time program. */ |
118 | typedef int (*rt_fn_t)(void*); | 118 | typedef int (*rt_fn_t)(void*); |
119 | 119 | ||
120 | /* These two functions configure the RT task to use enforced exe budgets. | 120 | /* exec another program as a real-time task. */ |
121 | * Partitioned scheduling: cluster = desired partition, cluster_size = 1 | 121 | int create_rt_task(rt_fn_t rt_prog, void *arg, struct rt_task* param); |
122 | * Global scheduling: cluster = 0, cluster_size = 0 | ||
123 | */ | ||
124 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, int cluster_size, | ||
125 | lt_t wcet, lt_t period, unsigned int prio); | ||
126 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, int cluster_size, | ||
127 | lt_t wcet, lt_t period, unsigned int prio, task_class_t cls); | ||
128 | 122 | ||
129 | /* per-task modes */ | 123 | /* per-task modes */ |
130 | enum rt_task_mode_t { | 124 | enum rt_task_mode_t { |
@@ -40,29 +40,16 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup, | |||
40 | return rt_task; | 40 | return rt_task; |
41 | } | 41 | } |
42 | 42 | ||
43 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, int cluster_size, | 43 | int create_rt_task(rt_fn_t rt_prog, void *arg, struct rt_task* param) |
44 | lt_t wcet, lt_t period, unsigned int priority, task_class_t cls) | ||
45 | { | 44 | { |
46 | struct rt_task params; | 45 | if (param->budget_policy == NO_ENFORCEMENT) { |
47 | init_rt_task_param(¶ms); | 46 | /* This is only safe if the task to be launched does not peg the CPU. |
48 | params.cpu = cluster_to_first_cpu(cluster, cluster_size); | 47 | That is, it must block frequently for I/O or call sleep_next_period() |
49 | params.period = period; | 48 | at the end of each job. Otherwise, the task may peg the CPU. */ |
50 | params.exec_cost = wcet; | 49 | //printf("Warning: running budget enforcement used.\n"); |
51 | params.cls = cls; | 50 | } |
52 | params.phase = 0; | ||
53 | params.priority = priority; | ||
54 | /* enforce budget for tasks that might not use sleep_next_period() */ | ||
55 | params.budget_policy = QUANTUM_ENFORCEMENT; | ||
56 | |||
57 | return __launch_rt_task(rt_prog, arg, | ||
58 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | ||
59 | } | ||
60 | 51 | ||
61 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, int cluster_size, | 52 | return __launch_rt_task(rt_prog, arg, (rt_setup_fn_t) set_rt_task_param, param); |
62 | lt_t wcet, lt_t period, unsigned int prio) | ||
63 | { | ||
64 | return __create_rt_task(rt_prog, arg, cluster, cluster_size, wcet, period, | ||
65 | prio, RT_CLASS_HARD); | ||
66 | } | 53 | } |
67 | 54 | ||
68 | 55 | ||