1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/* sched_plugin.c -- core infrastructure for the scheduler plugin system
*
* This file includes the initialization of the plugin system, the no-op Linux
* scheduler plugin and some dummy functions.
*/
#include <linux/litmus.h>
#include <linux/sched_plugin.h>
/* These are the original Linux initialization functions.
* We replace them here with our initialization code and call them
* after setting up LITMUS.
*/
void linux_sched_init(void);
void linux_sched_init_smp(void);
int linux_migration_init(void);
/*************************************************************
* Dummy plugin functions *
*************************************************************/
void litmus_dummy_finish_switch(struct task_struct * prev)
{
}
int litmus_dummy_schedule(struct task_struct * prev,
struct task_struct** next,
runqueue_t* q)
{
return 0;
}
reschedule_check_t litmus_dummy_scheduler_tick(void)
{
return NO_RESCHED;
}
long litmus_dummy_prepare_task(struct task_struct *t)
{
return 0;
}
void litmus_dummy_wake_up_task(struct task_struct *task)
{
printk(KERN_WARNING "task %d: unhandled real-time wake up!\n",
task->pid);
}
void litmus_dummy_task_blocks(struct task_struct *task)
{
}
long litmus_dummy_tear_down(struct task_struct *task)
{
return 0;
}
int litmus_dummy_scheduler_setup(int cmd, void __user *parameter)
{
return -EPERM;
}
long litmus_dummy_sleep_next_period(void)
{
return -EPERM;
}
long litmus_dummy_inherit_priority(struct pi_semaphore *sem,
struct task_struct *new_owner)
{
return -EPERM;
}
long litmus_dummy_return_priority(struct pi_semaphore *sem)
{
return -EPERM;
}
long litmus_dummy_pi_block(struct pi_semaphore *sem,
struct task_struct *new_waiter)
{
return -EPERM;
}
/* The default scheduler plugin. It doesn't do anything and lets Linux do its
* job.
*/
sched_plugin_t linux_sched_plugin = {
.plugin_name = "Linux",
.ready_to_use = 1,
.scheduler_tick = litmus_dummy_scheduler_tick,
.prepare_task = litmus_dummy_prepare_task,
.tear_down = litmus_dummy_tear_down,
.wake_up_task = litmus_dummy_wake_up_task,
.task_blocks = litmus_dummy_task_blocks,
.sleep_next_period = litmus_dummy_sleep_next_period,
.shutdown_hook = 0,
.schedule = litmus_dummy_schedule,
.finish_switch = litmus_dummy_finish_switch,
.scheduler_setup = litmus_dummy_scheduler_setup,
.inherit_priority = litmus_dummy_inherit_priority,
.return_priority = litmus_dummy_return_priority,
.pi_block = litmus_dummy_pi_block
};
/*
* The reference to current plugin that is used to schedule tasks within
* the system. It stores references to actual function implementations
* Should be initialized by calling "init_***_plugin()"
*/
sched_plugin_t *curr_sched_plugin = &linux_sched_plugin;
/* At sched-init */
void __init sched_init(void)
{
printk("Entering custom sched init, plugin %s\n",
curr_sched_plugin->plugin_name);
/* Init tracing facility before plugin functions are called */
/* CLEANUP: reenable this if needed
pstats = INIT_PSTATS;
*/
/* Call linux sched init tasks */
linux_sched_init();
printk("Sched init complete\n");
}
void __init sched_init_smp(void)
{
printk("Entering custom SMP init, plugin %s\n",
curr_sched_plugin->plugin_name);
/* Call linux smp initializer */
linux_sched_init_smp();
/* Enable tracing facilities here */
/*
CLEANUP: Reenable if needed.
if (smp_processor_id() == 0) {
if (init_trace()) {
printk("Tracing disabled\n");
} else {
printk("Default tracing enabled\n");
}
} */
printk("Sched init SMP complete\n");
}
int __init migration_init(void)
{
printk("Entering migration init\n");
/* Call linux migration init as it was before */
return linux_migration_init();
}
|