aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2011-01-28 14:22:27 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2011-01-28 14:30:43 -0500
commitb8be8fb192541fad88983ef6f9270cec1b51b59a (patch)
tree0ea9d579aa284cd156f228dc0e76da801c6792ee /include
parentd11808b5c6b032de4284281ed2ff77ae697a4ebd (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.h99
-rw-r--r--include/litmus/sched_plugin.h2
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 */
13typedef 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 */
27typedef int (*prio_compare_t)(struct task_struct*, struct task_struct*);
28typedef struct task_struct* (*take_ready_t)(rt_domain_t* rt);
29typedef void (*add_ready_t)(rt_domain_t* rt, struct task_struct *new);
30typedef void (*job_arrival_t)(struct task_struct* task);
31typedef void (*job_completion_t)(struct task_struct *t, int forced);
32
33
34struct 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
54extern 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 */
63int gbl_preemption_needed(struct task_struct *t);
64int gbl_ready_order(struct bheap_node* a, struct bheap_node* b);
65int gbl_cpu_lower_prio(struct bheap_node *_a, struct bheap_node *_b);
66void gbl_update_cpu_position(cpu_entry_t *entry);
67cpu_entry_t* gbl_lowest_prio_cpu(void);
68void gbl_link_task_to_cpu(struct task_struct* linked, cpu_entry_t *entry);
69void gbl_unlink(struct task_struct* t);
70void gbl_preempt(cpu_entry_t *entry);
71void gbl_requeue(struct task_struct* task);
72void gbl_check_for_preemptions(void);
73void gbl_release_jobs(rt_domain_t* rt, struct bheap* tasks);
74void gbl_job_completion(struct task_struct *t, int forced);
75
76/* Think of these two functions as "static" member functions */
77void gbl_domain_init(struct sched_global_plugin* gbl_plugin,
78 check_resched_needed_t resched,
79 release_jobs_t release);
80long 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 */
89void gblv_job_arrival(struct task_struct* task);
90void gblv_tick(struct task_struct* t);
91struct task_struct* gblv_schedule(struct task_struct * prev);
92void gblv_finish_switch(struct task_struct *prev);
93void gblv_task_new(struct task_struct * t, int on_rq, int running);
94void gblv_task_wake_up(struct task_struct *task);
95void gblv_task_block(struct task_struct *t);
96void gblv_task_exit(struct task_struct * t);
97long 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
26typedef long (*activate_plugin_t) (void); 26typedef long (*activate_plugin_t) (void* plugin);
27typedef long (*deactivate_plugin_t) (void); 27typedef long (*deactivate_plugin_t) (void);
28 28
29 29