diff options
author | Glenn Elliott <gelliott@koruna.cs.unc.edu> | 2010-05-20 14:33:27 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 11:27:34 -0400 |
commit | 6f89d4f31485546674187cf3b4d472f230b263d0 (patch) | |
tree | a9417ea7121e19228870b1e42b323f3bc149af2e | |
parent | 521422c4ef2c64731f709030915a7b301709f4b4 (diff) |
Added support for choices in budget policy enforcement.
NO_ENFORCEMENT - A job may execute beyond its declared execution time.
Jobs notify the kernel that they are complete via liblitmus's
sleep_next_period()
QUANTUM_ENFORCEMENT - The kernel terminates a job if its actual execution
time exceeds the declared execution time.
PRECISE_ENFORCEMENT - Hook declared, but not yet implemented. Plan to
support this policy through hrtimers. Error thrown if specified.
-rw-r--r-- | include/litmus/litmus.h | 2 | ||||
-rw-r--r-- | include/litmus/rt_param.h | 11 | ||||
-rw-r--r-- | litmus/litmus.c | 7 | ||||
-rw-r--r-- | litmus/sched_cedf.c | 6 | ||||
-rw-r--r-- | litmus/sched_gsn_edf.c | 6 | ||||
-rw-r--r-- | litmus/sched_psn_edf.c | 6 |
6 files changed, 30 insertions, 8 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index 62107e659c12..d515d1af1096 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
@@ -83,6 +83,8 @@ inline static int budget_exhausted(struct task_struct* t) | |||
83 | return get_exec_time(t) >= get_exec_cost(t); | 83 | return get_exec_time(t) >= get_exec_cost(t); |
84 | } | 84 | } |
85 | 85 | ||
86 | #define budget_enforced(t) (tsk_rt(t)->task_params.budget_policy != NO_ENFORCEMENT) | ||
87 | |||
86 | 88 | ||
87 | #define is_hrt(t) \ | 89 | #define is_hrt(t) \ |
88 | (tsk_rt(t)->task_params.class == RT_CLASS_HARD) | 90 | (tsk_rt(t)->task_params.class == RT_CLASS_HARD) |
diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index 5b94d1a8eea7..a7a183f34a80 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h | |||
@@ -27,12 +27,19 @@ typedef enum { | |||
27 | RT_CLASS_BEST_EFFORT | 27 | RT_CLASS_BEST_EFFORT |
28 | } task_class_t; | 28 | } task_class_t; |
29 | 29 | ||
30 | typedef enum { | ||
31 | NO_ENFORCEMENT, /* job may overrun unhindered */ | ||
32 | QUANTUM_ENFORCEMENT, /* budgets are only checked on quantum boundaries */ | ||
33 | PRECISE_ENFORCEMENT /* NOT IMPLEMENTED - enforced with hrtimers */ | ||
34 | } budget_policy_t; | ||
35 | |||
30 | struct rt_task { | 36 | struct rt_task { |
31 | lt_t exec_cost; | 37 | lt_t exec_cost; |
32 | lt_t period; | 38 | lt_t period; |
33 | lt_t phase; | 39 | lt_t phase; |
34 | unsigned int cpu; | 40 | unsigned int cpu; |
35 | task_class_t cls; | 41 | task_class_t cls; |
42 | budget_policy_t budget_policy; /* ignored by pfair */ | ||
36 | }; | 43 | }; |
37 | 44 | ||
38 | /* The definition of the data that is shared between the kernel and real-time | 45 | /* The definition of the data that is shared between the kernel and real-time |
diff --git a/litmus/litmus.c b/litmus/litmus.c index 99714d06eed5..86ad5b375934 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -112,6 +112,13 @@ asmlinkage long sys_set_rt_task_param(pid_t pid, struct rt_task __user * param) | |||
112 | "because wcet > period\n", pid); | 112 | "because wcet > period\n", pid); |
113 | goto out_unlock; | 113 | goto out_unlock; |
114 | } | 114 | } |
115 | if (tp.budget_policy != NO_ENFORCEMENT && | ||
116 | tp.budget_policy != QUANTUM_ENFORCEMENT) | ||
117 | { | ||
118 | printk(KERN_INFO "litmus: real-time task %d rejected " | ||
119 | "because unsupported budget enforcement policy specified\n", pid); | ||
120 | goto out_unlock; | ||
121 | } | ||
115 | 122 | ||
116 | target->rt_param.task_params = tp; | 123 | target->rt_param.task_params = tp; |
117 | 124 | ||
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 118fbd14fe25..82c9682eefbd 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c | |||
@@ -321,7 +321,7 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
321 | */ | 321 | */ |
322 | static void cedf_tick(struct task_struct* t) | 322 | static void cedf_tick(struct task_struct* t) |
323 | { | 323 | { |
324 | if (is_realtime(t) && budget_exhausted(t)) { | 324 | if (is_realtime(t) && budget_enforced(t) && budget_exhausted(t)) { |
325 | if (!is_np(t)) { | 325 | if (!is_np(t)) { |
326 | /* np tasks will be preempted when they become | 326 | /* np tasks will be preempted when they become |
327 | * preemptable again | 327 | * preemptable again |
@@ -379,7 +379,9 @@ static struct task_struct* cedf_schedule(struct task_struct * prev) | |||
379 | /* (0) Determine state */ | 379 | /* (0) Determine state */ |
380 | exists = entry->scheduled != NULL; | 380 | exists = entry->scheduled != NULL; |
381 | blocks = exists && !is_running(entry->scheduled); | 381 | blocks = exists && !is_running(entry->scheduled); |
382 | out_of_time = exists && budget_exhausted(entry->scheduled); | 382 | out_of_time = exists && |
383 | budget_enforced(entry->scheduled) && | ||
384 | budget_exhausted(entry->scheduled); | ||
383 | np = exists && is_np(entry->scheduled); | 385 | np = exists && is_np(entry->scheduled); |
384 | sleep = exists && get_rt_flags(entry->scheduled) == RT_F_SLEEP; | 386 | sleep = exists && get_rt_flags(entry->scheduled) == RT_F_SLEEP; |
385 | preempt = entry->scheduled != entry->linked; | 387 | preempt = entry->scheduled != entry->linked; |
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index 7424c183d8b2..c0c63eba70ce 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c | |||
@@ -336,7 +336,7 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
336 | */ | 336 | */ |
337 | static void gsnedf_tick(struct task_struct* t) | 337 | static void gsnedf_tick(struct task_struct* t) |
338 | { | 338 | { |
339 | if (is_realtime(t) && budget_exhausted(t)) { | 339 | if (is_realtime(t) && budget_enforced(t) && budget_exhausted(t)) { |
340 | if (!is_np(t)) { | 340 | if (!is_np(t)) { |
341 | /* np tasks will be preempted when they become | 341 | /* np tasks will be preempted when they become |
342 | * preemptable again | 342 | * preemptable again |
@@ -399,7 +399,9 @@ static struct task_struct* gsnedf_schedule(struct task_struct * prev) | |||
399 | /* (0) Determine state */ | 399 | /* (0) Determine state */ |
400 | exists = entry->scheduled != NULL; | 400 | exists = entry->scheduled != NULL; |
401 | blocks = exists && !is_running(entry->scheduled); | 401 | blocks = exists && !is_running(entry->scheduled); |
402 | out_of_time = exists && budget_exhausted(entry->scheduled); | 402 | out_of_time = exists && |
403 | budget_enforced(entry->scheduled) && | ||
404 | budget_exhausted(entry->scheduled); | ||
403 | np = exists && is_np(entry->scheduled); | 405 | np = exists && is_np(entry->scheduled); |
404 | sleep = exists && get_rt_flags(entry->scheduled) == RT_F_SLEEP; | 406 | sleep = exists && get_rt_flags(entry->scheduled) == RT_F_SLEEP; |
405 | preempt = entry->scheduled != entry->linked; | 407 | preempt = entry->scheduled != entry->linked; |
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c index 7a548bf5162e..e50b27391d21 100644 --- a/litmus/sched_psn_edf.c +++ b/litmus/sched_psn_edf.c | |||
@@ -107,7 +107,7 @@ static void psnedf_tick(struct task_struct *t) | |||
107 | */ | 107 | */ |
108 | BUG_ON(is_realtime(t) && t != pedf->scheduled); | 108 | BUG_ON(is_realtime(t) && t != pedf->scheduled); |
109 | 109 | ||
110 | if (is_realtime(t) && budget_exhausted(t)) { | 110 | if (is_realtime(t) && budget_enforced(t) && budget_exhausted(t)) { |
111 | if (!is_np(t)) { | 111 | if (!is_np(t)) { |
112 | set_tsk_need_resched(t); | 112 | set_tsk_need_resched(t); |
113 | TRACE("psnedf_scheduler_tick: " | 113 | TRACE("psnedf_scheduler_tick: " |
@@ -143,7 +143,9 @@ static struct task_struct* psnedf_schedule(struct task_struct * prev) | |||
143 | /* (0) Determine state */ | 143 | /* (0) Determine state */ |
144 | exists = pedf->scheduled != NULL; | 144 | exists = pedf->scheduled != NULL; |
145 | blocks = exists && !is_running(pedf->scheduled); | 145 | blocks = exists && !is_running(pedf->scheduled); |
146 | out_of_time = exists && budget_exhausted(pedf->scheduled); | 146 | out_of_time = exists && |
147 | budget_enforced(pedf->scheduled) && | ||
148 | budget_exhausted(pedf->scheduled); | ||
147 | np = exists && is_np(pedf->scheduled); | 149 | np = exists && is_np(pedf->scheduled); |
148 | sleep = exists && get_rt_flags(pedf->scheduled) == RT_F_SLEEP; | 150 | sleep = exists && get_rt_flags(pedf->scheduled) == RT_F_SLEEP; |
149 | preempt = edf_preemption_needed(edf, prev); | 151 | preempt = edf_preemption_needed(edf, prev); |