RTEMS 7.0-rc1
Loading...
Searching...
No Matches
scheduler.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2020 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_CONFDEFS_SCHEDULER_H
38#define _RTEMS_CONFDEFS_SCHEDULER_H
39
40#ifndef __CONFIGURATION_TEMPLATE_h
41#error "Do not include this file directly, use <rtems/confdefs.h> instead"
42#endif
43
44#ifdef CONFIGURE_INIT
45
47
48#if !defined(CONFIGURE_SCHEDULER_CBS) \
49 && !defined(CONFIGURE_SCHEDULER_EDF) \
50 && !defined(CONFIGURE_SCHEDULER_EDF_SMP) \
51 && !defined(CONFIGURE_SCHEDULER_PRIORITY) \
52 && !defined(CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP) \
53 && !defined(CONFIGURE_SCHEDULER_PRIORITY_SMP) \
54 && !defined(CONFIGURE_SCHEDULER_SIMPLE) \
55 && !defined(CONFIGURE_SCHEDULER_SIMPLE_SMP) \
56 && !defined(CONFIGURE_SCHEDULER_STRONG_APA) \
57 && !defined(CONFIGURE_SCHEDULER_USER)
58 #if defined(RTEMS_SMP) && _CONFIGURE_MAXIMUM_PROCESSORS > 1
59 #define CONFIGURE_SCHEDULER_EDF_SMP
60 #else
61 #define CONFIGURE_SCHEDULER_PRIORITY
62 #endif
63#endif
64
65#include <rtems/scheduler.h>
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71#ifndef CONFIGURE_MAXIMUM_PRIORITY
72 #define CONFIGURE_MAXIMUM_PRIORITY PRIORITY_DEFAULT_MAXIMUM
73#endif
74
75#if !defined(CONFIGURE_SCHEDULER_EDF) && \
76 !defined(CONFIGURE_SCHEDULER_EDF_SMP) && \
77 !defined(CONFIGURE_SCHEDULER_CBS)
78
79#if CONFIGURE_MAXIMUM_PRIORITY != 3 \
80 && CONFIGURE_MAXIMUM_PRIORITY != 7 \
81 && CONFIGURE_MAXIMUM_PRIORITY != 15 \
82 && CONFIGURE_MAXIMUM_PRIORITY != 31 \
83 && CONFIGURE_MAXIMUM_PRIORITY != 63 \
84 && CONFIGURE_MAXIMUM_PRIORITY != 127 \
85 && CONFIGURE_MAXIMUM_PRIORITY != 255
86 #error "CONFIGURE_MAXIMUM_PRIORITY must be one of 3, 7, 15, 31, 63, 127, and 255"
87#endif
88
89#if CONFIGURE_MAXIMUM_PRIORITY > PRIORITY_DEFAULT_MAXIMUM
90 #error "CONFIGURE_SCHEDULER_PRIORITY must be less than or equal to the architecture defined maximum priority"
91#endif
92
93#endif
94
95#ifdef CONFIGURE_SCHEDULER_PRIORITY
96 #ifndef CONFIGURE_SCHEDULER_NAME
97 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'U', 'P', 'D', ' ' )
98 #endif
99
100 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
101 #define CONFIGURE_SCHEDULER \
102 RTEMS_SCHEDULER_PRIORITY( \
103 dflt, \
104 CONFIGURE_MAXIMUM_PRIORITY + 1 \
105 )
106
107 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
108 RTEMS_SCHEDULER_TABLE_PRIORITY( dflt, CONFIGURE_SCHEDULER_NAME )
109 #endif
110#endif
111
112#ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
113 #ifndef CONFIGURE_SCHEDULER_NAME
114 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'M', 'P', 'D', ' ' )
115 #endif
116
117 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
118 #define CONFIGURE_SCHEDULER \
119 RTEMS_SCHEDULER_PRIORITY_SMP( \
120 dflt, \
121 CONFIGURE_MAXIMUM_PRIORITY + 1 \
122 )
123
124 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
125 RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( dflt, CONFIGURE_SCHEDULER_NAME )
126 #endif
127#endif
128
129#ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
130 #ifndef CONFIGURE_SCHEDULER_NAME
131 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'M', 'P', 'A', ' ' )
132 #endif
133
134 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
135 #define CONFIGURE_SCHEDULER \
136 RTEMS_SCHEDULER_PRIORITY_AFFINITY_SMP( \
137 dflt, \
138 CONFIGURE_MAXIMUM_PRIORITY + 1 \
139 )
140
141 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
142 RTEMS_SCHEDULER_TABLE_PRIORITY_AFFINITY_SMP( \
143 dflt, \
144 CONFIGURE_SCHEDULER_NAME \
145 )
146 #endif
147#endif
148
149#ifdef CONFIGURE_SCHEDULER_STRONG_APA
150 #ifndef CONFIGURE_SCHEDULER_NAME
151 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'M', 'A', 'P', 'A' )
152 #endif
153
154 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
155 #define CONFIGURE_SCHEDULER \
156 RTEMS_SCHEDULER_STRONG_APA( \
157 dflt, \
158 CONFIGURE_MAXIMUM_PRIORITY + 1 \
159 )
160
161 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
162 RTEMS_SCHEDULER_TABLE_STRONG_APA( dflt, CONFIGURE_SCHEDULER_NAME )
163 #endif
164#endif
165
166#ifdef CONFIGURE_SCHEDULER_SIMPLE
167 #ifndef CONFIGURE_SCHEDULER_NAME
168 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'U', 'P', 'S', ' ' )
169 #endif
170
171 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
172 #define CONFIGURE_SCHEDULER RTEMS_SCHEDULER_SIMPLE( dflt )
173
174 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
175 RTEMS_SCHEDULER_TABLE_SIMPLE( dflt, CONFIGURE_SCHEDULER_NAME )
176 #endif
177#endif
178
179#ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
180 #ifndef CONFIGURE_SCHEDULER_NAME
181 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'M', 'P', 'S', ' ' )
182 #endif
183
184 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
185 #define CONFIGURE_SCHEDULER \
186 RTEMS_SCHEDULER_SIMPLE_SMP( dflt )
187
188 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
189 RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( dflt, CONFIGURE_SCHEDULER_NAME )
190 #endif
191#endif
192
193#ifdef CONFIGURE_SCHEDULER_EDF
194 #ifndef CONFIGURE_SCHEDULER_NAME
195 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'U', 'E', 'D', 'F' )
196 #endif
197
198 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
199 #define CONFIGURE_SCHEDULER RTEMS_SCHEDULER_EDF( dflt )
200
201 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
202 RTEMS_SCHEDULER_TABLE_EDF( dflt, CONFIGURE_SCHEDULER_NAME )
203 #endif
204#endif
205
206#ifdef CONFIGURE_SCHEDULER_EDF_SMP
207 #ifndef CONFIGURE_SCHEDULER_NAME
208 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'M', 'E', 'D', 'F' )
209 #endif
210
211 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
212 #define CONFIGURE_SCHEDULER RTEMS_SCHEDULER_EDF_SMP( dflt )
213
214 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
215 RTEMS_SCHEDULER_TABLE_EDF_SMP( dflt, CONFIGURE_SCHEDULER_NAME )
216 #endif
217#endif
218
219#ifdef CONFIGURE_SCHEDULER_CBS
220 #ifndef CONFIGURE_SCHEDULER_NAME
221 #define CONFIGURE_SCHEDULER_NAME rtems_build_name( 'U', 'C', 'B', 'S' )
222 #endif
223
224 #ifndef CONFIGURE_SCHEDULER_TABLE_ENTRIES
225 #define CONFIGURE_SCHEDULER RTEMS_SCHEDULER_CBS( dflt )
226
227 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
228 RTEMS_SCHEDULER_TABLE_CBS( dflt, CONFIGURE_SCHEDULER_NAME )
229 #endif
230
231 #ifndef CONFIGURE_CBS_MAXIMUM_SERVERS
232 #define CONFIGURE_CBS_MAXIMUM_SERVERS CONFIGURE_MAXIMUM_TASKS
233 #endif
234
235 const uint32_t _Scheduler_CBS_Maximum_servers =
237
240#endif
241
242#ifdef CONFIGURE_SCHEDULER
243 /*
244 * Ignore these warnings:
245 *
246 * - invalid use of structure with flexible array member
247 *
248 * - struct has no members
249 */
250 #pragma GCC diagnostic push
251 #pragma GCC diagnostic ignored "-Wpedantic"
252 CONFIGURE_SCHEDULER;
253 #pragma GCC diagnostic pop
254#endif
255
258};
259
260#define _CONFIGURE_SCHEDULER_COUNT RTEMS_ARRAY_SIZE( _Scheduler_Table )
261
262#ifdef RTEMS_SMP
263
264const size_t _Scheduler_Count = _CONFIGURE_SCHEDULER_COUNT;
265
266const Scheduler_Assignment _Scheduler_Initial_assignments[] = {
267 #ifdef CONFIGURE_SCHEDULER_ASSIGNMENTS
269 #else
270 #define _CONFIGURE_SCHEDULER_ASSIGN \
271 RTEMS_SCHEDULER_ASSIGN( \
272 0, \
273 RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \
274 )
275 _CONFIGURE_SCHEDULER_ASSIGN
276 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 2
277 , _CONFIGURE_SCHEDULER_ASSIGN
278 #endif
279 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 3
280 , _CONFIGURE_SCHEDULER_ASSIGN
281 #endif
282 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 4
283 , _CONFIGURE_SCHEDULER_ASSIGN
284 #endif
285 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 5
286 , _CONFIGURE_SCHEDULER_ASSIGN
287 #endif
288 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 6
289 , _CONFIGURE_SCHEDULER_ASSIGN
290 #endif
291 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 7
292 , _CONFIGURE_SCHEDULER_ASSIGN
293 #endif
294 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 8
295 , _CONFIGURE_SCHEDULER_ASSIGN
296 #endif
297 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 9
298 , _CONFIGURE_SCHEDULER_ASSIGN
299 #endif
300 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 10
301 , _CONFIGURE_SCHEDULER_ASSIGN
302 #endif
303 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 11
304 , _CONFIGURE_SCHEDULER_ASSIGN
305 #endif
306 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 12
307 , _CONFIGURE_SCHEDULER_ASSIGN
308 #endif
309 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 13
310 , _CONFIGURE_SCHEDULER_ASSIGN
311 #endif
312 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 14
313 , _CONFIGURE_SCHEDULER_ASSIGN
314 #endif
315 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 15
316 , _CONFIGURE_SCHEDULER_ASSIGN
317 #endif
318 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 16
319 , _CONFIGURE_SCHEDULER_ASSIGN
320 #endif
321 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 17
322 , _CONFIGURE_SCHEDULER_ASSIGN
323 #endif
324 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 18
325 , _CONFIGURE_SCHEDULER_ASSIGN
326 #endif
327 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 19
328 , _CONFIGURE_SCHEDULER_ASSIGN
329 #endif
330 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 20
331 , _CONFIGURE_SCHEDULER_ASSIGN
332 #endif
333 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 21
334 , _CONFIGURE_SCHEDULER_ASSIGN
335 #endif
336 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 22
337 , _CONFIGURE_SCHEDULER_ASSIGN
338 #endif
339 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 23
340 , _CONFIGURE_SCHEDULER_ASSIGN
341 #endif
342 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 24
343 , _CONFIGURE_SCHEDULER_ASSIGN
344 #endif
345 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 25
346 , _CONFIGURE_SCHEDULER_ASSIGN
347 #endif
348 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 26
349 , _CONFIGURE_SCHEDULER_ASSIGN
350 #endif
351 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 27
352 , _CONFIGURE_SCHEDULER_ASSIGN
353 #endif
354 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 28
355 , _CONFIGURE_SCHEDULER_ASSIGN
356 #endif
357 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 29
358 , _CONFIGURE_SCHEDULER_ASSIGN
359 #endif
360 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 30
361 , _CONFIGURE_SCHEDULER_ASSIGN
362 #endif
363 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 31
364 , _CONFIGURE_SCHEDULER_ASSIGN
365 #endif
366 #if _CONFIGURE_MAXIMUM_PROCESSORS >= 32
367 , _CONFIGURE_SCHEDULER_ASSIGN
368 #endif
369 #undef _CONFIGURE_SCHEDULER_ASSIGN
370 #endif
371};
372
374 _CONFIGURE_MAXIMUM_PROCESSORS
375 == RTEMS_ARRAY_SIZE( _Scheduler_Initial_assignments ),
376 _Scheduler_Initial_assignments
377);
378
379#endif /* RTEMS_SMP */
380
381#ifdef __cplusplus
382}
383#endif
384
385#endif /* CONFIGURE_INIT */
386
387#endif /* _RTEMS_CONFDEFS_SCHEDULER_H */
This header file evaluates configuration options related to the per-CPU configuration.
#define RTEMS_STATIC_ASSERT(_cond, _msg)
It is defined if a static analysis run is performed.
Definition: basedefs.h:866
#define RTEMS_ARRAY_SIZE(_array)
Gets the element count of the array.
Definition: basedefs.h:244
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES
This configuration option is an initializer define.
Definition: appl-config.h:5016
#define CONFIGURE_SCHEDULER_ASSIGNMENTS
This configuration option is an initializer define.
Definition: appl-config.h:4607
#define CONFIGURE_CBS_MAXIMUM_SERVERS
This configuration option is an integer define.
Definition: appl-config.h:4495
Scheduler_CBS_Server _Scheduler_CBS_Server_list[]
const uint32_t _Scheduler_CBS_Maximum_servers
#define _Scheduler_Count
This constant contains the count of configured schedulers.
Definition: scheduler.h:395
const Scheduler_Control _Scheduler_Table[]
This table contains the configured schedulers.
Definition: schedulercbs.h:131
Scheduler control.
Definition: scheduler.h:337