diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2011-01-28 14:22:27 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2011-01-28 14:30:43 -0500 |
commit | b8be8fb192541fad88983ef6f9270cec1b51b59a (patch) | |
tree | 0ea9d579aa284cd156f228dc0e76da801c6792ee /include | |
parent | d11808b5c6b032de4284281ed2ff77ae697a4ebd (diff) |
Generalizd architecture for GEDF-style scheduelrs to reduce code redundancy.wip-refactored-gedf
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/litmus/sched_global_plugin.h | 99 | ||||
-rw-r--r-- | include/litmus/sched_plugin.h | 2 |
2 files changed, 100 insertions, 1 deletions
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 @@ | |||
1 | #ifndef _LITMUS_SCHED_GLOBAL_PLUGIN_H_ | ||
2 | |||
3 | |||
4 | #include <linux/sched.h> | ||
5 | |||
6 | #include <litmus/litmus.h> | ||
7 | #include <litmus/sched_plugin.h> | ||
8 | #include <litmus/rt_domain.h> | ||
9 | #include <litmus/bheap.h> | ||
10 | |||
11 | /* cpu_entry_t - maintain the linked and scheduled state | ||
12 | */ | ||
13 | typedef struct { | ||
14 | int cpu; | ||
15 | struct task_struct* linked; /* only RT tasks */ | ||
16 | struct task_struct* scheduled; /* only RT tasks */ | ||
17 | struct bheap_node* hn; | ||
18 | } cpu_entry_t; | ||
19 | |||
20 | |||
21 | /* | ||
22 | For use by G-EDF family of plugins (G-EDF, EDZL, etc.). | ||
23 | These plugins differ mainly by actual rt_domain_t and | ||
24 | priority-order comparator functions and a few hooks for | ||
25 | timers. | ||
26 | */ | ||
27 | typedef int (*prio_compare_t)(struct task_struct*, struct task_struct*); | ||
28 | typedef struct task_struct* (*take_ready_t)(rt_domain_t* rt); | ||
29 | typedef void (*add_ready_t)(rt_domain_t* rt, struct task_struct *new); | ||
30 | typedef void (*job_arrival_t)(struct task_struct* task); | ||
31 | typedef void (*job_completion_t)(struct task_struct *t, int forced); | ||
32 | |||
33 | |||
34 | struct sched_global_plugin { | ||
35 | |||
36 | struct sched_plugin plugin; | ||
37 | |||
38 | /* function pointers MUST be set by plugin */ | ||
39 | prio_compare_t prio_order; | ||
40 | take_ready_t take_ready; | ||
41 | add_ready_t add_ready; | ||
42 | job_arrival_t job_arrival; | ||
43 | job_completion_t job_completion; | ||
44 | |||
45 | rt_domain_t domain; | ||
46 | |||
47 | cpu_entry_t* cpus[NR_CPUS]; | ||
48 | struct bheap_node heap_node[NR_CPUS]; | ||
49 | struct bheap cpu_heap; | ||
50 | |||
51 | } __attribute__ ((__aligned__(SMP_CACHE_BYTES))); | ||
52 | |||
53 | |||
54 | extern struct sched_global_plugin* active_gbl_plugin; | ||
55 | |||
56 | |||
57 | /* | ||
58 | * "Member" functions for generic global scheduling. | ||
59 | * Will call down into "virtual" functions as needed. | ||
60 | * | ||
61 | * Use prefix "gbl_" (global) | ||
62 | */ | ||
63 | int gbl_preemption_needed(struct task_struct *t); | ||
64 | int gbl_ready_order(struct bheap_node* a, struct bheap_node* b); | ||
65 | int gbl_cpu_lower_prio(struct bheap_node *_a, struct bheap_node *_b); | ||
66 | void gbl_update_cpu_position(cpu_entry_t *entry); | ||
67 | cpu_entry_t* gbl_lowest_prio_cpu(void); | ||
68 | void gbl_link_task_to_cpu(struct task_struct* linked, cpu_entry_t *entry); | ||
69 | void gbl_unlink(struct task_struct* t); | ||
70 | void gbl_preempt(cpu_entry_t *entry); | ||
71 | void gbl_requeue(struct task_struct* task); | ||
72 | void gbl_check_for_preemptions(void); | ||
73 | void gbl_release_jobs(rt_domain_t* rt, struct bheap* tasks); | ||
74 | void gbl_job_completion(struct task_struct *t, int forced); | ||
75 | |||
76 | /* Think of these two functions as "static" member functions */ | ||
77 | void gbl_domain_init(struct sched_global_plugin* gbl_plugin, | ||
78 | check_resched_needed_t resched, | ||
79 | release_jobs_t release); | ||
80 | long gbl_activate_plugin(void* plugin); | ||
81 | |||
82 | |||
83 | /* | ||
84 | * "Virtual member" functions for generic global scheduling. | ||
85 | * For use with sched_plugin or sched_global_plugin. | ||
86 | * | ||
87 | * Use prefix "gblv_" (global virtual) | ||
88 | */ | ||
89 | void gblv_job_arrival(struct task_struct* task); | ||
90 | void gblv_tick(struct task_struct* t); | ||
91 | struct task_struct* gblv_schedule(struct task_struct * prev); | ||
92 | void gblv_finish_switch(struct task_struct *prev); | ||
93 | void gblv_task_new(struct task_struct * t, int on_rq, int running); | ||
94 | void gblv_task_wake_up(struct task_struct *task); | ||
95 | void gblv_task_block(struct task_struct *t); | ||
96 | void gblv_task_exit(struct task_struct * t); | ||
97 | long gblv_admit_task(struct task_struct* tsk); | ||
98 | |||
99 | #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 { | |||
23 | 23 | ||
24 | /************************ setup/tear down ********************/ | 24 | /************************ setup/tear down ********************/ |
25 | 25 | ||
26 | typedef long (*activate_plugin_t) (void); | 26 | typedef long (*activate_plugin_t) (void* plugin); |
27 | typedef long (*deactivate_plugin_t) (void); | 27 | typedef long (*deactivate_plugin_t) (void); |
28 | 28 | ||
29 | 29 | ||