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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
#ifndef LITMUS_EXT_RESERVATION_H
#define LITMUS_EXT_RESERVATION_H
#include <linux/list.h>
#include <linux/sched.h>
#include <litmus/rt_param.h>
#include <litmus/debug_trace.h>
#include <litmus/reservations/budget-notifier.h>
#ifdef CONFIG_LITMUS_LOCKING
#include <litmus/locking.h>
#endif
struct ext_reservation_environment;
struct ext_reservation;
int higher_res_prio(
struct ext_reservation* first,
struct ext_reservation* second
);
/* ************************************************************************** */
/* Reservation replenishes its budget. */
typedef void (*replenish_budget_t) (
struct ext_reservation *reservation,
int cpu
);
/* Update the reservation's budget to reflect execution or idling. */
typedef void (*drain_budget_ext_t) (
struct ext_reservation *reservation,
lt_t how_much,
int cpu
);
typedef struct task_struct* (*dispatch_client_ext_t) (
struct ext_reservation *reservation,
lt_t* time_slice,
int cpu
);
/* When reservation is scheduled. */
typedef void (*on_schedule_t) (
struct ext_reservation *reservation,
int cpu
);
/* When reservation is preempted. */
typedef void (*on_preempt_t) (
struct ext_reservation *reservation,
int cpu
);
typedef int (*is_np_t) (
struct ext_reservation *reservation,
int cpu
);
/* Destructor: called before scheduler is deactivated. */
typedef void (*shutdown_ext_t)(
struct ext_reservation *reservation
);
struct ext_reservation_ops {
drain_budget_ext_t drain_budget;
replenish_budget_t replenish_budget;
dispatch_client_ext_t dispatch_client;
on_schedule_t on_schedule;
on_preempt_t on_preempt;
is_np_t is_np;
shutdown_ext_t shutdown;
};
struct ext_reservation {
unsigned int id;
/* exact meaning defined by impl. */
lt_t priority;
lt_t replenishment_time;
lt_t cur_budget;
/* budget stats */
lt_t budget_consumed; /* how much budget consumed in this allocation cycle? */
lt_t budget_consumed_total;
/* for memory reclamation purposes */
struct list_head all_list;
/* interaction with framework */
struct ext_reservation_ops *ops;
struct ext_reservation_environment* par_env;
struct ext_reservation_environment* env;
/* used to enqueue int rt_domain framework */
struct bheap_node* heap_node;
struct release_heap* rel_heap;
struct list_head ln;
#ifdef CONFIG_LITMUS_LOCKING
/* reservation representing the current "inherited" reservation
* priority, assigned by the scheduler plugins.
* could point to self if PI does not result in
* an increased task priority.
*/
struct ext_reservation* inh_res;
#endif
};
void init_ext_reservation(
struct ext_reservation* res,
unsigned int id,
struct ext_reservation_ops* ops);
void clean_up_ext_reservation(struct ext_reservation* res);
/* ************************************************************************** */
typedef void (*env_update_time_t) (
struct ext_reservation_environment* env,
lt_t how_much,
int cpu);
typedef struct task_struct* (*env_dispatch_t) (
struct ext_reservation_environment* env,
lt_t* time_slice,
int cpu);
typedef void (*env_resume_t) (
struct ext_reservation_environment* env,
int cpu);
typedef void (*env_suspend_t) (
struct ext_reservation_environment* env,
int cpu);
typedef void (*env_add_res_t) (
struct ext_reservation_environment* env,
struct ext_reservation* res,
int cpu);
typedef void (*env_remove_res_t) (
struct ext_reservation_environment* env,
struct ext_reservation* res,
int complete,
int cpu);
typedef struct ext_reservation* (*env_find_res_t) (
struct ext_reservation_environment* env,
int id);
typedef int (*env_is_np_t) (
struct ext_reservation_environment* env,
int cpu);
typedef void (*env_shutdown_t) (
struct ext_reservation_environment* env);
#ifdef CONFIG_LITMUS_LOCKING
/* Called when the current task attempts to create a new lock of a given
* protocol type. */
typedef long (*env_allocate_lock_t) (
struct ext_reservation_environment* env,
struct litmus_lock **lock,
int type,
void* __user config);
#endif
struct ext_reservation_environment_ops {
env_update_time_t update_time;
env_dispatch_t dispatch;
env_resume_t resume;
env_suspend_t suspend;
env_add_res_t add_res;
env_remove_res_t remove_res;
env_find_res_t find_res_by_id;
env_is_np_t is_np;
env_shutdown_t shutdown;
#ifdef CONFIG_LITMUS_LOCKING
/* locking protocols */
env_allocate_lock_t allocate_lock;
#endif
};
struct ext_reservation_environment {
struct ext_reservation_environment_ops* ops;
struct ext_reservation* res;
struct list_head all_reservations;
};
#endif
|