aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-02-19 13:41:40 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-04-30 15:52:38 -0400
commitf6e75bd3b6715dbf77a9b60e56a094e934a8feaf (patch)
tree2f3cd8768132fe7cc9e2af75103d3e7758f8159d
parent2e2a2df9647e5e982134b67d37981036bb512146 (diff)
litmus: move job release functions to common code
-rw-r--r--include/litmus/edf_common.h9
-rw-r--r--include/litmus/jobs.h9
-rw-r--r--litmus/Makefile4
-rw-r--r--litmus/edf_common.c37
-rw-r--r--litmus/jobs.c43
-rw-r--r--litmus/sched_gsn_edf.c9
-rw-r--r--litmus/sched_psn_edf.c9
7 files changed, 64 insertions, 56 deletions
diff --git a/include/litmus/edf_common.h b/include/litmus/edf_common.h
index f3c930b137..dd40e1c882 100644
--- a/include/litmus/edf_common.h
+++ b/include/litmus/edf_common.h
@@ -19,17 +19,8 @@ int edf_higher_prio(struct task_struct* first,
19 19
20int edf_ready_order(struct list_head* a, struct list_head* b); 20int edf_ready_order(struct list_head* a, struct list_head* b);
21 21
22void edf_release_at(struct task_struct *t, lt_t start);
23
24int edf_preemption_needed(rt_domain_t* rt, struct task_struct *t); 22int edf_preemption_needed(rt_domain_t* rt, struct task_struct *t);
25long edf_complete_job(void);
26
27void edf_prepare_for_next_period(struct task_struct *t);
28
29#define job_completed(t) (!is_be(t) && \
30 (t)->rt_param.times.exec_time == (t)->rt_param.basic_params.exec_cost)
31 23
32int edf_set_hp_task(struct pi_semaphore *sem); 24int edf_set_hp_task(struct pi_semaphore *sem);
33int edf_set_hp_cpu_task(struct pi_semaphore *sem, int cpu); 25int edf_set_hp_cpu_task(struct pi_semaphore *sem, int cpu);
34
35#endif 26#endif
diff --git a/include/litmus/jobs.h b/include/litmus/jobs.h
new file mode 100644
index 0000000000..9bd361ef39
--- /dev/null
+++ b/include/litmus/jobs.h
@@ -0,0 +1,9 @@
1#ifndef __LITMUS_JOBS_H__
2#define __LITMUS_JOBS_H__
3
4void prepare_for_next_period(struct task_struct *t);
5void release_at(struct task_struct *t, lt_t start);
6long complete_job(void);
7
8#endif
9
diff --git a/litmus/Makefile b/litmus/Makefile
index 4ad854f117..a6a9f8797d 100644
--- a/litmus/Makefile
+++ b/litmus/Makefile
@@ -3,6 +3,6 @@
3# 3#
4 4
5obj-y = sched_plugin.o litmus.o sched_trace.o \ 5obj-y = sched_plugin.o litmus.o sched_trace.o \
6 edf_common.o \ 6 edf_common.o jobs.o\
7 sched_gsn_edf.o sched_psn_edf.o litmus_sem.o \ 7 sched_gsn_edf.o sched_psn_edf.o litmus_sem.o \
8 trace.o ft_event.o rt_domain.o fdso.o 8 trace.o ft_event.o rt_domain.o fdso.o sync.o
diff --git a/litmus/edf_common.c b/litmus/edf_common.c
index 3d9dca852d..2a52835a04 100644
--- a/litmus/edf_common.c
+++ b/litmus/edf_common.c
@@ -67,32 +67,11 @@ int edf_ready_order(struct list_head* a, struct list_head* b)
67 list_entry(b, struct task_struct, rt_list)); 67 list_entry(b, struct task_struct, rt_list));
68} 68}
69 69
70void edf_release_at(struct task_struct *t, lt_t start)
71{
72 t->rt_param.job_params.deadline = start;
73 edf_prepare_for_next_period(t);
74 set_rt_flags(t, RT_F_RUNNING);
75}
76
77void edf_domain_init(rt_domain_t* rt, check_resched_needed_t resched) 70void edf_domain_init(rt_domain_t* rt, check_resched_needed_t resched)
78{ 71{
79 rt_domain_init(rt, resched, edf_ready_order); 72 rt_domain_init(rt, resched, edf_ready_order);
80} 73}
81 74
82void edf_prepare_for_next_period(struct task_struct *t)
83{
84 BUG_ON(!t);
85 /* prepare next release */
86 t->rt_param.job_params.release = t->rt_param.job_params.deadline;
87 t->rt_param.job_params.deadline += get_rt_period(t);
88 t->rt_param.job_params.exec_time = 0;
89 /* update job sequence number */
90 t->rt_param.job_params.job_no++;
91
92 /* don't confuse Linux */
93 t->time_slice = 1;
94}
95
96/* need_to_preempt - check whether the task t needs to be preempted 75/* need_to_preempt - check whether the task t needs to be preempted
97 * call only with irqs disabled and with ready_lock acquired 76 * call only with irqs disabled and with ready_lock acquired
98 * THIS DOES NOT TAKE NON-PREEMPTIVE SECTIONS INTO ACCOUNT! 77 * THIS DOES NOT TAKE NON-PREEMPTIVE SECTIONS INTO ACCOUNT!
@@ -114,19 +93,3 @@ int edf_preemption_needed(rt_domain_t* rt, struct task_struct *t)
114 /* make sure to get non-rt stuff out of the way */ 93 /* make sure to get non-rt stuff out of the way */
115 return !is_realtime(t) || edf_higher_prio(next_ready(rt), t); 94 return !is_realtime(t) || edf_higher_prio(next_ready(rt), t);
116} 95}
117
118
119/*
120 * Deactivate current task until the beginning of the next period.
121 */
122long edf_complete_job(void)
123{
124 /* Mark that we do not excute anymore */
125 set_rt_flags(current, RT_F_SLEEP);
126 /* call schedule, this will return when a new job arrives
127 * it also takes care of preparing for the next release
128 */
129 schedule();
130 return 0;
131}
132
diff --git a/litmus/jobs.c b/litmus/jobs.c
new file mode 100644
index 0000000000..e294bc5b12
--- /dev/null
+++ b/litmus/jobs.c
@@ -0,0 +1,43 @@
1/* litmus/jobs.c - common job control code
2 */
3
4#include <linux/sched.h>
5
6#include <litmus/litmus.h>
7#include <litmus/jobs.h>
8
9void prepare_for_next_period(struct task_struct *t)
10{
11 BUG_ON(!t);
12 /* prepare next release */
13 t->rt_param.job_params.release = t->rt_param.job_params.deadline;
14 t->rt_param.job_params.deadline += get_rt_period(t);
15 t->rt_param.job_params.exec_time = 0;
16 /* update job sequence number */
17 t->rt_param.job_params.job_no++;
18
19 /* don't confuse Linux */
20 t->time_slice = 1;
21}
22
23void release_at(struct task_struct *t, lt_t start)
24{
25 t->rt_param.job_params.deadline = start;
26 prepare_for_next_period(t);
27 set_rt_flags(t, RT_F_RUNNING);
28}
29
30
31/*
32 * Deactivate current task until the beginning of the next period.
33 */
34long complete_job(void)
35{
36 /* Mark that we do not excute anymore */
37 set_rt_flags(current, RT_F_SLEEP);
38 /* call schedule, this will return when a new job arrives
39 * it also takes care of preparing for the next release
40 */
41 schedule();
42 return 0;
43}
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c
index e879b02888..7a7d9a2dfb 100644
--- a/litmus/sched_gsn_edf.c
+++ b/litmus/sched_gsn_edf.c
@@ -14,6 +14,7 @@
14#include <linux/list.h> 14#include <linux/list.h>
15 15
16#include <litmus/litmus.h> 16#include <litmus/litmus.h>
17#include <litmus/jobs.h>
17#include <litmus/sched_plugin.h> 18#include <litmus/sched_plugin.h>
18#include <litmus/edf_common.h> 19#include <litmus/edf_common.h>
19#include <litmus/sched_trace.h> 20#include <litmus/sched_trace.h>
@@ -385,7 +386,7 @@ static noinline void job_completion(struct task_struct *t)
385 /* set flags */ 386 /* set flags */
386 set_rt_flags(t, RT_F_SLEEP); 387 set_rt_flags(t, RT_F_SLEEP);
387 /* prepare for next period */ 388 /* prepare for next period */
388 edf_prepare_for_next_period(t); 389 prepare_for_next_period(t);
389 /* unlink */ 390 /* unlink */
390 unlink(t); 391 unlink(t);
391 /* requeue 392 /* requeue
@@ -524,7 +525,7 @@ static void gsnedf_task_new(struct task_struct * t, int on_rq, int running)
524 t->rt_param.linked_on = NO_CPU; 525 t->rt_param.linked_on = NO_CPU;
525 526
526 /* setup job params */ 527 /* setup job params */
527 edf_release_at(t, sched_clock()); 528 release_at(t, sched_clock());
528 529
529 gsnedf_job_arrival(t); 530 gsnedf_job_arrival(t);
530 spin_unlock_irqrestore(&gsnedf_lock, flags); 531 spin_unlock_irqrestore(&gsnedf_lock, flags);
@@ -546,7 +547,7 @@ static void gsnedf_task_wake_up(struct task_struct *task)
546 now = sched_clock(); 547 now = sched_clock();
547 if (is_tardy(task, now)) { 548 if (is_tardy(task, now)) {
548 /* new sporadic release */ 549 /* new sporadic release */
549 edf_release_at(task, now); 550 release_at(task, now);
550 sched_trace_job_release(task); 551 sched_trace_job_release(task);
551 } 552 }
552 else if (task->time_slice) 553 else if (task->time_slice)
@@ -684,7 +685,7 @@ static struct sched_plugin gsn_edf_plugin __cacheline_aligned_in_smp = {
684 .finish_switch = gsnedf_finish_switch, 685 .finish_switch = gsnedf_finish_switch,
685 .tick = gsnedf_tick, 686 .tick = gsnedf_tick,
686 .task_new = gsnedf_task_new, 687 .task_new = gsnedf_task_new,
687 .complete_job = edf_complete_job, 688 .complete_job = complete_job,
688 .task_exit = gsnedf_task_exit, 689 .task_exit = gsnedf_task_exit,
689 .schedule = gsnedf_schedule, 690 .schedule = gsnedf_schedule,
690 .task_wake_up = gsnedf_task_wake_up, 691 .task_wake_up = gsnedf_task_wake_up,
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c
index 961680d0a6..81c6f1d69a 100644
--- a/litmus/sched_psn_edf.c
+++ b/litmus/sched_psn_edf.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19#include <litmus/litmus.h> 19#include <litmus/litmus.h>
20#include <litmus/jobs.h>
20#include <litmus/sched_plugin.h> 21#include <litmus/sched_plugin.h>
21#include <litmus/edf_common.h> 22#include <litmus/edf_common.h>
22 23
@@ -132,7 +133,7 @@ static void job_completion(struct task_struct* t)
132{ 133{
133 TRACE_TASK(t, "job_completion().\n"); 134 TRACE_TASK(t, "job_completion().\n");
134 set_rt_flags(t, RT_F_SLEEP); 135 set_rt_flags(t, RT_F_SLEEP);
135 edf_prepare_for_next_period(t); 136 prepare_for_next_period(t);
136} 137}
137 138
138static struct task_struct* psnedf_schedule(struct task_struct * prev) 139static struct task_struct* psnedf_schedule(struct task_struct * prev)
@@ -225,7 +226,7 @@ static void psnedf_task_new(struct task_struct * t, int on_rq, int running)
225 smp_processor_id(), t->pid, get_partition(t)); 226 smp_processor_id(), t->pid, get_partition(t));
226 227
227 /* setup job parameters */ 228 /* setup job parameters */
228 edf_release_at(t, sched_clock()); 229 release_at(t, sched_clock());
229 230
230 /* The task should be running in the queue, otherwise signal 231 /* The task should be running in the queue, otherwise signal
231 * code will try to wake it up with fatal consequences. 232 * code will try to wake it up with fatal consequences.
@@ -262,7 +263,7 @@ static void psnedf_task_wake_up(struct task_struct *task)
262 if (is_tardy(task, now) && 263 if (is_tardy(task, now) &&
263 get_rt_flags(task) != RT_F_EXIT_SEM) { 264 get_rt_flags(task) != RT_F_EXIT_SEM) {
264 /* new sporadic release */ 265 /* new sporadic release */
265 edf_release_at(task, now); 266 release_at(task, now);
266 sched_trace_job_release(task); 267 sched_trace_job_release(task);
267 } 268 }
268 requeue(task, edf); 269 requeue(task, edf);
@@ -411,7 +412,7 @@ static struct sched_plugin psn_edf_plugin __cacheline_aligned_in_smp = {
411 .plugin_name = "PSN-EDF", 412 .plugin_name = "PSN-EDF",
412 .tick = psnedf_tick, 413 .tick = psnedf_tick,
413 .task_new = psnedf_task_new, 414 .task_new = psnedf_task_new,
414 .complete_job = edf_complete_job, 415 .complete_job = complete_job,
415 .task_exit = psnedf_task_exit, 416 .task_exit = psnedf_task_exit,
416 .schedule = psnedf_schedule, 417 .schedule = psnedf_schedule,
417 .task_wake_up = psnedf_task_wake_up, 418 .task_wake_up = psnedf_task_wake_up,