aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@koruna.cs.unc.edu>2010-05-20 14:17:58 -0400
committerGlenn Elliott <gelliott@koruna.cs.unc.edu>2010-05-20 14:17:58 -0400
commite9c900fae35e4e4730469e189ff17bf30518346a (patch)
tree73d399b98f831fae4a7251a7d3d143ac044d6684
parent09740315d4b914203c25c56e8f8909b4fae7b32d (diff)
Support budget enforcement policies. Allows tasks to specify
how their execution budgets should be enforced: NO_ENFORCEMENT, QUANTUM_ENFORCEMENT, and PRECISE_ENFORCEMENT (unsupported). NOTE: Users of NO_ENFORCEMENT must call sleep_next_period() at the end of every job to signal to the kernel that its job is complete.
-rw-r--r--bin/rtspin.c2
-rw-r--r--include/litmus.h19
-rw-r--r--src/litmus.c10
-rw-r--r--src/task.c3
4 files changed, 24 insertions, 10 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c
index aa97745..f291869 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -221,7 +221,7 @@ int main(int argc, char** argv)
221 bail_out("could not migrate to target partition"); 221 bail_out("could not migrate to target partition");
222 } 222 }
223 223
224 ret = sporadic_task_ns(wcet, period, 0, cpu, class, migrate); 224 ret = sporadic_task_ns(wcet, period, 0, cpu, class, NO_ENFORCEMENT, migrate);
225 225
226 if (ret < 0) 226 if (ret < 0)
227 bail_out("could not setup rt task params"); 227 bail_out("could not setup rt task params");
diff --git a/include/litmus.h b/include/litmus.h
index e0f16d3..b798c92 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -27,18 +27,24 @@ int set_rt_task_param(pid_t pid, struct rt_task* param);
27int get_rt_task_param(pid_t pid, struct rt_task* param); 27int get_rt_task_param(pid_t pid, struct rt_task* param);
28 28
29/* setup helper */ 29/* setup helper */
30
30/* times are given in ms */ 31/* times are given in ms */
31int sporadic_task(lt_t e, lt_t p, lt_t phase, 32int sporadic_task(
32 int partition, task_class_t cls, int set_cpu_set); 33 lt_t e, lt_t p, lt_t phase,
34 int partition, task_class_t cls,
35 budget_policy_t budget_policy, int set_cpu_set);
33 36
34/* times are given in ns */ 37/* times are given in ns */
35int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, 38int sporadic_task_ns(
36 int cpu, task_class_t cls, int set_cpu_set); 39 lt_t e, lt_t p, lt_t phase,
40 int cpu, task_class_t cls,
41 budget_policy_t budget_policy, int set_cpu_set);
37 42
43/* budget enforcement off by default in these macros */
38#define sporadic_global(e, p) \ 44#define sporadic_global(e, p) \
39 sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, 0) 45 sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0)
40#define sporadic_partitioned(e, p, cpu) \ 46#define sporadic_partitioned(e, p, cpu) \
41 sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, 1) 47 sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1)
42 48
43/* file descriptor attached shared objects support */ 49/* file descriptor attached shared objects support */
44typedef enum { 50typedef enum {
@@ -75,6 +81,7 @@ void exit_litmus(void);
75/* A real-time program. */ 81/* A real-time program. */
76typedef int (*rt_fn_t)(void*); 82typedef int (*rt_fn_t)(void*);
77 83
84/* These two functions configure the RT task to use enforced exe budgets */
78int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); 85int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period);
79int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, 86int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet,
80 int period, task_class_t cls); 87 int period, task_class_t cls);
diff --git a/src/litmus.c b/src/litmus.c
index 5f98b97..f71f337 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -42,14 +42,16 @@ int be_migrate_to(int target_cpu)
42} 42}
43 43
44int sporadic_task(lt_t e, lt_t p, lt_t phase, 44int sporadic_task(lt_t e, lt_t p, lt_t phase,
45 int cpu, task_class_t cls, int set_cpu_set) 45 int cpu, task_class_t cls,
46 budget_policy_t budget_policy, int set_cpu_set)
46{ 47{
47 return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, 48 return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS,
48 cpu, cls, set_cpu_set); 49 cpu, cls, budget_policy, set_cpu_set);
49} 50}
50 51
51int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, 52int sporadic_task_ns(lt_t e, lt_t p, lt_t phase,
52 int cpu, task_class_t cls, int set_cpu_set) 53 int cpu, task_class_t cls,
54 budget_policy_t budget_policy, int set_cpu_set)
53{ 55{
54 struct rt_task param; 56 struct rt_task param;
55 int ret; 57 int ret;
@@ -58,6 +60,8 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase,
58 param.cpu = cpu; 60 param.cpu = cpu;
59 param.cls = cls; 61 param.cls = cls;
60 param.phase = phase; 62 param.phase = phase;
63 param.budget_policy = budget_policy;
64
61 if (set_cpu_set) { 65 if (set_cpu_set) {
62 ret = be_migrate_to(cpu); 66 ret = be_migrate_to(cpu);
63 check("migrate to cpu"); 67 check("migrate to cpu");
diff --git a/src/task.c b/src/task.c
index f9e4ccf..4d237bd 100644
--- a/src/task.c
+++ b/src/task.c
@@ -49,6 +49,9 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period,
49 params.exec_cost = wcet; 49 params.exec_cost = wcet;
50 params.cls = class; 50 params.cls = class;
51 params.phase = 0; 51 params.phase = 0;
52 /* enforce budget for tasks that might not use sleep_next_period() */
53 params.budget_policy = QUANTUM_ENFORCEMENT;
54
52 return __launch_rt_task(rt_prog, arg, 55 return __launch_rt_task(rt_prog, arg,
53 (rt_setup_fn_t) set_rt_task_param, &params); 56 (rt_setup_fn_t) set_rt_task_param, &params);
54} 57}