From f6e75bd3b6715dbf77a9b60e56a094e934a8feaf Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Tue, 19 Feb 2008 13:41:40 -0500 Subject: litmus: move job release functions to common code --- include/litmus/edf_common.h | 9 --------- include/litmus/jobs.h | 9 +++++++++ litmus/Makefile | 4 ++-- litmus/edf_common.c | 37 ------------------------------------- litmus/jobs.c | 43 +++++++++++++++++++++++++++++++++++++++++++ litmus/sched_gsn_edf.c | 9 +++++---- litmus/sched_psn_edf.c | 9 +++++---- 7 files changed, 64 insertions(+), 56 deletions(-) create mode 100644 include/litmus/jobs.h create mode 100644 litmus/jobs.c 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, int edf_ready_order(struct list_head* a, struct list_head* b); -void edf_release_at(struct task_struct *t, lt_t start); - int edf_preemption_needed(rt_domain_t* rt, struct task_struct *t); -long edf_complete_job(void); - -void edf_prepare_for_next_period(struct task_struct *t); - -#define job_completed(t) (!is_be(t) && \ - (t)->rt_param.times.exec_time == (t)->rt_param.basic_params.exec_cost) int edf_set_hp_task(struct pi_semaphore *sem); int edf_set_hp_cpu_task(struct pi_semaphore *sem, int cpu); - #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 @@ +#ifndef __LITMUS_JOBS_H__ +#define __LITMUS_JOBS_H__ + +void prepare_for_next_period(struct task_struct *t); +void release_at(struct task_struct *t, lt_t start); +long complete_job(void); + +#endif + diff --git a/litmus/Makefile b/litmus/Makefile index 4ad854f117..a6a9f8797d 100644 --- a/litmus/Makefile +++ b/litmus/Makefile @@ -3,6 +3,6 @@ # obj-y = sched_plugin.o litmus.o sched_trace.o \ - edf_common.o \ + edf_common.o jobs.o\ sched_gsn_edf.o sched_psn_edf.o litmus_sem.o \ - trace.o ft_event.o rt_domain.o fdso.o + 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) list_entry(b, struct task_struct, rt_list)); } -void edf_release_at(struct task_struct *t, lt_t start) -{ - t->rt_param.job_params.deadline = start; - edf_prepare_for_next_period(t); - set_rt_flags(t, RT_F_RUNNING); -} - void edf_domain_init(rt_domain_t* rt, check_resched_needed_t resched) { rt_domain_init(rt, resched, edf_ready_order); } -void edf_prepare_for_next_period(struct task_struct *t) -{ - BUG_ON(!t); - /* prepare next release */ - t->rt_param.job_params.release = t->rt_param.job_params.deadline; - t->rt_param.job_params.deadline += get_rt_period(t); - t->rt_param.job_params.exec_time = 0; - /* update job sequence number */ - t->rt_param.job_params.job_no++; - - /* don't confuse Linux */ - t->time_slice = 1; -} - /* need_to_preempt - check whether the task t needs to be preempted * call only with irqs disabled and with ready_lock acquired * 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) /* make sure to get non-rt stuff out of the way */ return !is_realtime(t) || edf_higher_prio(next_ready(rt), t); } - - -/* - * Deactivate current task until the beginning of the next period. - */ -long edf_complete_job(void) -{ - /* Mark that we do not excute anymore */ - set_rt_flags(current, RT_F_SLEEP); - /* call schedule, this will return when a new job arrives - * it also takes care of preparing for the next release - */ - schedule(); - return 0; -} - 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 @@ +/* litmus/jobs.c - common job control code + */ + +#include + +#include +#include + +void prepare_for_next_period(struct task_struct *t) +{ + BUG_ON(!t); + /* prepare next release */ + t->rt_param.job_params.release = t->rt_param.job_params.deadline; + t->rt_param.job_params.deadline += get_rt_period(t); + t->rt_param.job_params.exec_time = 0; + /* update job sequence number */ + t->rt_param.job_params.job_no++; + + /* don't confuse Linux */ + t->time_slice = 1; +} + +void release_at(struct task_struct *t, lt_t start) +{ + t->rt_param.job_params.deadline = start; + prepare_for_next_period(t); + set_rt_flags(t, RT_F_RUNNING); +} + + +/* + * Deactivate current task until the beginning of the next period. + */ +long complete_job(void) +{ + /* Mark that we do not excute anymore */ + set_rt_flags(current, RT_F_SLEEP); + /* call schedule, this will return when a new job arrives + * it also takes care of preparing for the next release + */ + schedule(); + return 0; +} 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 @@ #include #include +#include #include #include #include @@ -385,7 +386,7 @@ static noinline void job_completion(struct task_struct *t) /* set flags */ set_rt_flags(t, RT_F_SLEEP); /* prepare for next period */ - edf_prepare_for_next_period(t); + prepare_for_next_period(t); /* unlink */ unlink(t); /* requeue @@ -524,7 +525,7 @@ static void gsnedf_task_new(struct task_struct * t, int on_rq, int running) t->rt_param.linked_on = NO_CPU; /* setup job params */ - edf_release_at(t, sched_clock()); + release_at(t, sched_clock()); gsnedf_job_arrival(t); spin_unlock_irqrestore(&gsnedf_lock, flags); @@ -546,7 +547,7 @@ static void gsnedf_task_wake_up(struct task_struct *task) now = sched_clock(); if (is_tardy(task, now)) { /* new sporadic release */ - edf_release_at(task, now); + release_at(task, now); sched_trace_job_release(task); } else if (task->time_slice) @@ -684,7 +685,7 @@ static struct sched_plugin gsn_edf_plugin __cacheline_aligned_in_smp = { .finish_switch = gsnedf_finish_switch, .tick = gsnedf_tick, .task_new = gsnedf_task_new, - .complete_job = edf_complete_job, + .complete_job = complete_job, .task_exit = gsnedf_task_exit, .schedule = gsnedf_schedule, .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 @@ #include #include +#include #include #include @@ -132,7 +133,7 @@ static void job_completion(struct task_struct* t) { TRACE_TASK(t, "job_completion().\n"); set_rt_flags(t, RT_F_SLEEP); - edf_prepare_for_next_period(t); + prepare_for_next_period(t); } static 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) smp_processor_id(), t->pid, get_partition(t)); /* setup job parameters */ - edf_release_at(t, sched_clock()); + release_at(t, sched_clock()); /* The task should be running in the queue, otherwise signal * code will try to wake it up with fatal consequences. @@ -262,7 +263,7 @@ static void psnedf_task_wake_up(struct task_struct *task) if (is_tardy(task, now) && get_rt_flags(task) != RT_F_EXIT_SEM) { /* new sporadic release */ - edf_release_at(task, now); + release_at(task, now); sched_trace_job_release(task); } requeue(task, edf); @@ -411,7 +412,7 @@ static struct sched_plugin psn_edf_plugin __cacheline_aligned_in_smp = { .plugin_name = "PSN-EDF", .tick = psnedf_tick, .task_new = psnedf_task_new, - .complete_job = edf_complete_job, + .complete_job = complete_job, .task_exit = psnedf_task_exit, .schedule = psnedf_schedule, .task_wake_up = psnedf_task_wake_up, -- cgit v1.2.2