From b8be8fb192541fad88983ef6f9270cec1b51b59a Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Fri, 28 Jan 2011 14:22:27 -0500 Subject: Generalizd architecture for GEDF-style scheduelrs to reduce code redundancy. This patch hoists nearly all of the non-GEDF specific code (decision making (GEDF) vs. carrying out decisions (non-specific)) out of sched_gsn_edf.c and into a new generic sched_global_plugin architecture. A new struct, sched_global_plugin, provides the needed hooks for other GEDF-style schedulers to reuse the non-scheduler-specific code. You may conceptualize this new architecture (in OO-terms) as: * sched_plugin is the parent of sched_global_plugin. * sched_global_plugin is the parent of gsn_edf_plugin. * Both sched_plugin and sched_global_plugin are "pure virtual" This patch drastically reduces the amount of code needed to support G-EDF, EDZL, (Adaptive) EDZL, etc. --- include/litmus/sched_global_plugin.h | 99 ++++++++++++++++++++++++++++++++++++ include/litmus/sched_plugin.h | 2 +- 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 include/litmus/sched_global_plugin.h (limited to 'include') diff --git a/include/litmus/sched_global_plugin.h b/include/litmus/sched_global_plugin.h new file mode 100644 index 000000000000..cac2de63a3ee --- /dev/null +++ b/include/litmus/sched_global_plugin.h @@ -0,0 +1,99 @@ +#ifndef _LITMUS_SCHED_GLOBAL_PLUGIN_H_ + + +#include + +#include +#include +#include +#include + +/* cpu_entry_t - maintain the linked and scheduled state + */ +typedef struct { + int cpu; + struct task_struct* linked; /* only RT tasks */ + struct task_struct* scheduled; /* only RT tasks */ + struct bheap_node* hn; +} cpu_entry_t; + + +/* + For use by G-EDF family of plugins (G-EDF, EDZL, etc.). + These plugins differ mainly by actual rt_domain_t and + priority-order comparator functions and a few hooks for + timers. + */ +typedef int (*prio_compare_t)(struct task_struct*, struct task_struct*); +typedef struct task_struct* (*take_ready_t)(rt_domain_t* rt); +typedef void (*add_ready_t)(rt_domain_t* rt, struct task_struct *new); +typedef void (*job_arrival_t)(struct task_struct* task); +typedef void (*job_completion_t)(struct task_struct *t, int forced); + + +struct sched_global_plugin { + + struct sched_plugin plugin; + + /* function pointers MUST be set by plugin */ + prio_compare_t prio_order; + take_ready_t take_ready; + add_ready_t add_ready; + job_arrival_t job_arrival; + job_completion_t job_completion; + + rt_domain_t domain; + + cpu_entry_t* cpus[NR_CPUS]; + struct bheap_node heap_node[NR_CPUS]; + struct bheap cpu_heap; + +} __attribute__ ((__aligned__(SMP_CACHE_BYTES))); + + +extern struct sched_global_plugin* active_gbl_plugin; + + +/* + * "Member" functions for generic global scheduling. + * Will call down into "virtual" functions as needed. + * + * Use prefix "gbl_" (global) + */ +int gbl_preemption_needed(struct task_struct *t); +int gbl_ready_order(struct bheap_node* a, struct bheap_node* b); +int gbl_cpu_lower_prio(struct bheap_node *_a, struct bheap_node *_b); +void gbl_update_cpu_position(cpu_entry_t *entry); +cpu_entry_t* gbl_lowest_prio_cpu(void); +void gbl_link_task_to_cpu(struct task_struct* linked, cpu_entry_t *entry); +void gbl_unlink(struct task_struct* t); +void gbl_preempt(cpu_entry_t *entry); +void gbl_requeue(struct task_struct* task); +void gbl_check_for_preemptions(void); +void gbl_release_jobs(rt_domain_t* rt, struct bheap* tasks); +void gbl_job_completion(struct task_struct *t, int forced); + +/* Think of these two functions as "static" member functions */ +void gbl_domain_init(struct sched_global_plugin* gbl_plugin, + check_resched_needed_t resched, + release_jobs_t release); +long gbl_activate_plugin(void* plugin); + + +/* + * "Virtual member" functions for generic global scheduling. + * For use with sched_plugin or sched_global_plugin. + * + * Use prefix "gblv_" (global virtual) + */ +void gblv_job_arrival(struct task_struct* task); +void gblv_tick(struct task_struct* t); +struct task_struct* gblv_schedule(struct task_struct * prev); +void gblv_finish_switch(struct task_struct *prev); +void gblv_task_new(struct task_struct * t, int on_rq, int running); +void gblv_task_wake_up(struct task_struct *task); +void gblv_task_block(struct task_struct *t); +void gblv_task_exit(struct task_struct * t); +long gblv_admit_task(struct task_struct* tsk); + +#endif \ No newline at end of file diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h index 2d856d587041..6899816ea321 100644 --- a/include/litmus/sched_plugin.h +++ b/include/litmus/sched_plugin.h @@ -23,7 +23,7 @@ struct pi_semaphore { /************************ setup/tear down ********************/ -typedef long (*activate_plugin_t) (void); +typedef long (*activate_plugin_t) (void* plugin); typedef long (*deactivate_plugin_t) (void); -- cgit v1.2.2