diff options
Diffstat (limited to 'include/litmus/sched_plugin.h')
-rw-r--r-- | include/litmus/sched_plugin.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h new file mode 100644 index 00000000000..1546ab7f1d6 --- /dev/null +++ b/include/litmus/sched_plugin.h | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Definition of the scheduler plugin interface. | ||
3 | * | ||
4 | */ | ||
5 | #ifndef _LINUX_SCHED_PLUGIN_H_ | ||
6 | #define _LINUX_SCHED_PLUGIN_H_ | ||
7 | |||
8 | #include <linux/sched.h> | ||
9 | |||
10 | #ifdef CONFIG_LITMUS_LOCKING | ||
11 | #include <litmus/locking.h> | ||
12 | #endif | ||
13 | |||
14 | /************************ setup/tear down ********************/ | ||
15 | |||
16 | typedef long (*activate_plugin_t) (void); | ||
17 | typedef long (*deactivate_plugin_t) (void); | ||
18 | |||
19 | |||
20 | |||
21 | /********************* scheduler invocation ******************/ | ||
22 | |||
23 | /* Plugin-specific realtime tick handler */ | ||
24 | typedef void (*scheduler_tick_t) (struct task_struct *cur); | ||
25 | /* Novell make sched decision function */ | ||
26 | typedef struct task_struct* (*schedule_t)(struct task_struct * prev); | ||
27 | /* Clean up after the task switch has occured. | ||
28 | * This function is called after every (even non-rt) task switch. | ||
29 | */ | ||
30 | typedef void (*finish_switch_t)(struct task_struct *prev); | ||
31 | |||
32 | |||
33 | /********************* task state changes ********************/ | ||
34 | |||
35 | /* Called to setup a new real-time task. | ||
36 | * Release the first job, enqueue, etc. | ||
37 | * Task may already be running. | ||
38 | */ | ||
39 | typedef void (*task_new_t) (struct task_struct *task, | ||
40 | int on_rq, | ||
41 | int running); | ||
42 | |||
43 | /* Called to re-introduce a task after blocking. | ||
44 | * Can potentially be called multiple times. | ||
45 | */ | ||
46 | typedef void (*task_wake_up_t) (struct task_struct *task); | ||
47 | /* called to notify the plugin of a blocking real-time task | ||
48 | * it will only be called for real-time tasks and before schedule is called */ | ||
49 | typedef void (*task_block_t) (struct task_struct *task); | ||
50 | /* Called when a real-time task exits or changes to a different scheduling | ||
51 | * class. | ||
52 | * Free any allocated resources | ||
53 | */ | ||
54 | typedef void (*task_exit_t) (struct task_struct *); | ||
55 | |||
56 | #ifdef CONFIG_LITMUS_LOCKING | ||
57 | /* Called when the current task attempts to create a new lock of a given | ||
58 | * protocol type. */ | ||
59 | typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type, | ||
60 | void* __user config); | ||
61 | #endif | ||
62 | |||
63 | |||
64 | /********************* sys call backends ********************/ | ||
65 | /* This function causes the caller to sleep until the next release */ | ||
66 | typedef long (*complete_job_t) (void); | ||
67 | |||
68 | typedef long (*admit_task_t)(struct task_struct* tsk); | ||
69 | |||
70 | typedef void (*release_at_t)(struct task_struct *t, lt_t start); | ||
71 | |||
72 | struct sched_plugin { | ||
73 | struct list_head list; | ||
74 | /* basic info */ | ||
75 | char *plugin_name; | ||
76 | |||
77 | /* setup */ | ||
78 | activate_plugin_t activate_plugin; | ||
79 | deactivate_plugin_t deactivate_plugin; | ||
80 | |||
81 | /* scheduler invocation */ | ||
82 | scheduler_tick_t tick; | ||
83 | schedule_t schedule; | ||
84 | finish_switch_t finish_switch; | ||
85 | |||
86 | /* syscall backend */ | ||
87 | complete_job_t complete_job; | ||
88 | release_at_t release_at; | ||
89 | |||
90 | /* task state changes */ | ||
91 | admit_task_t admit_task; | ||
92 | |||
93 | task_new_t task_new; | ||
94 | task_wake_up_t task_wake_up; | ||
95 | task_block_t task_block; | ||
96 | task_exit_t task_exit; | ||
97 | |||
98 | #ifdef CONFIG_LITMUS_LOCKING | ||
99 | /* locking protocols */ | ||
100 | allocate_lock_t allocate_lock; | ||
101 | #endif | ||
102 | } __attribute__ ((__aligned__(SMP_CACHE_BYTES))); | ||
103 | |||
104 | |||
105 | extern struct sched_plugin *litmus; | ||
106 | |||
107 | int register_sched_plugin(struct sched_plugin* plugin); | ||
108 | struct sched_plugin* find_sched_plugin(const char* name); | ||
109 | int print_sched_plugins(char* buf, int max); | ||
110 | |||
111 | extern struct sched_plugin linux_sched_plugin; | ||
112 | |||
113 | #endif | ||