RTEMS  5.0.0
scheduler.h
Go to the documentation of this file.
1 
7 /*
8  * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved.
9  *
10  * embedded brains GmbH
11  * Dornierstr. 4
12  * 82178 Puchheim
13  * Germany
14  * <rtems@embedded-brains.de>
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #ifndef _RTEMS_SAPI_SCHEDULER_H
22 #define _RTEMS_SAPI_SCHEDULER_H
23 
24 #include <rtems/score/scheduler.h>
25 
26 #define SCHEDULER_CONTEXT_NAME( name ) \
27  _Configuration_Scheduler_ ## name
28 
29 #if defined(RTEMS_SMP)
30  /* This object doesn't exist and indicates a configuration error */
31  extern const Scheduler_Control RTEMS_SCHEDULER_INVALID_INDEX;
32 
33  #define RTEMS_SCHEDULER_ASSIGN_DEFAULT \
34  SCHEDULER_ASSIGN_DEFAULT
35 
36  #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \
37  SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL
38 
39  #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY \
40  SCHEDULER_ASSIGN_PROCESSOR_MANDATORY
41 
42  #define RTEMS_SCHEDULER_ASSIGN( index, attr ) \
43  { \
44  ( index ) < RTEMS_ARRAY_SIZE( _Scheduler_Table ) ? \
45  &_Scheduler_Table[ ( index ) ] : &RTEMS_SCHEDULER_INVALID_INDEX, \
46  ( attr ) \
47  }
48 
49  #define RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER { NULL, 0 }
50 #endif
51 
52 /*
53  * This file should be only included in the context of <rtems/confdefs.h>.
54  * Define the scheduler configuration macros only in case the corresponding
55  * configure symbol is defined. This is necessary to prevent invalid workspace
56  * size estimates since we have to account for the per-thread scheduler
57  * information.
58  */
59 
60 #ifdef CONFIGURE_SCHEDULER_CBS
62 
63  #define SCHEDULER_CBS_CONTEXT_NAME( name ) \
64  SCHEDULER_CONTEXT_NAME( CBS_ ## name )
65 
66  #define RTEMS_SCHEDULER_CBS( name ) \
67  static Scheduler_EDF_Context SCHEDULER_CBS_CONTEXT_NAME( name )
68 
69  #define RTEMS_SCHEDULER_TABLE_CBS( name, obj_name ) \
70  { \
71  &SCHEDULER_CBS_CONTEXT_NAME( name ).Base, \
72  SCHEDULER_CBS_ENTRY_POINTS, \
73  SCHEDULER_CBS_MAXIMUM_PRIORITY, \
74  ( obj_name ) \
75  }
76 
77  /* Provided for backward compatibility */
78 
79  #define RTEMS_SCHEDULER_CONTEXT_CBS( name ) \
80  RTEMS_SCHEDULER_CBS( name )
81 
82  #define RTEMS_SCHEDULER_CONTROL_CBS( name, obj_name ) \
83  RTEMS_SCHEDULER_TABLE_CBS( name, obj_name )
84 #endif
85 
86 #ifdef CONFIGURE_SCHEDULER_EDF
88 
89  #define SCHEDULER_EDF_CONTEXT_NAME( name ) \
90  SCHEDULER_CONTEXT_NAME( EDF_ ## name )
91 
92  #define RTEMS_SCHEDULER_EDF( name ) \
93  static Scheduler_EDF_Context SCHEDULER_EDF_CONTEXT_NAME( name )
94 
95  #define RTEMS_SCHEDULER_TABLE_EDF( name, obj_name ) \
96  { \
97  &SCHEDULER_EDF_CONTEXT_NAME( name ).Base, \
98  SCHEDULER_EDF_ENTRY_POINTS, \
99  SCHEDULER_EDF_MAXIMUM_PRIORITY, \
100  ( obj_name ) \
101  }
102 
103  /* Provided for backward compatibility */
104 
105  #define RTEMS_SCHEDULER_CONTEXT_EDF( name ) \
106  RTEMS_SCHEDULER_EDF( name )
107 
108  #define RTEMS_SCHEDULER_CONTROL_EDF( name, obj_name ) \
109  RTEMS_SCHEDULER_TABLE_EDF( name, obj_name )
110 #endif
111 
112 #ifdef CONFIGURE_SCHEDULER_EDF_SMP
114 
115  #define SCHEDULER_EDF_SMP_CONTEXT_NAME( name ) \
116  SCHEDULER_CONTEXT_NAME( EDF_SMP_ ## name )
117 
118  #define RTEMS_SCHEDULER_EDF_SMP( name, max_cpu_count ) \
119  static struct { \
120  Scheduler_EDF_SMP_Context Base; \
121  Scheduler_EDF_SMP_Ready_queue Ready[ ( max_cpu_count ) + 1 ]; \
122  } SCHEDULER_EDF_SMP_CONTEXT_NAME( name )
123 
124  #define RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name ) \
125  { \
126  &SCHEDULER_EDF_SMP_CONTEXT_NAME( name ).Base.Base.Base, \
127  SCHEDULER_EDF_SMP_ENTRY_POINTS, \
128  SCHEDULER_EDF_MAXIMUM_PRIORITY, \
129  ( obj_name ) \
130  }
131 
132  /* Provided for backward compatibility */
133 
134  #define RTEMS_SCHEDULER_CONTEXT_EDF_SMP( name, max_cpu_count ) \
135  RTEMS_SCHEDULER_EDF_SMP( name, max_cpu_count )
136 
137  #define RTEMS_SCHEDULER_CONTROL_EDF_SMP( name, obj_name ) \
138  RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name )
139 #endif
140 
141 #ifdef CONFIGURE_SCHEDULER_PRIORITY
143 
144  #define SCHEDULER_PRIORITY_CONTEXT_NAME( name ) \
145  SCHEDULER_CONTEXT_NAME( priority_ ## name )
146 
147  #define RTEMS_SCHEDULER_PRIORITY( name, prio_count ) \
148  static struct { \
149  Scheduler_priority_Context Base; \
150  Chain_Control Ready[ ( prio_count ) ]; \
151  } SCHEDULER_PRIORITY_CONTEXT_NAME( name )
152 
153  #define RTEMS_SCHEDULER_TABLE_PRIORITY( name, obj_name ) \
154  { \
155  &SCHEDULER_PRIORITY_CONTEXT_NAME( name ).Base.Base, \
156  SCHEDULER_PRIORITY_ENTRY_POINTS, \
157  RTEMS_ARRAY_SIZE( \
158  SCHEDULER_PRIORITY_CONTEXT_NAME( name ).Ready \
159  ) - 1, \
160  ( obj_name ) \
161  }
162 
163  /* Provided for backward compatibility */
164 
165  #define RTEMS_SCHEDULER_CONTEXT_PRIORITY( name, prio_count ) \
166  RTEMS_SCHEDULER_PRIORITY( name, prio_count )
167 
168  #define RTEMS_SCHEDULER_CONTROL_PRIORITY( name, obj_name ) \
169  RTEMS_SCHEDULER_TABLE_PRIORITY( name, obj_name )
170 #endif
171 
172 #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
174 
175  #define SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ) \
176  SCHEDULER_CONTEXT_NAME( priority_affinity_SMP_ ## name )
177 
178  #define RTEMS_SCHEDULER_PRIORITY_AFFINITY_SMP( name, prio_count ) \
179  static struct { \
180  Scheduler_priority_SMP_Context Base; \
181  Chain_Control Ready[ ( prio_count ) ]; \
182  } SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name )
183 
184  #define RTEMS_SCHEDULER_TABLE_PRIORITY_AFFINITY_SMP( name, obj_name ) \
185  { \
186  &SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ).Base.Base.Base, \
187  SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS, \
188  RTEMS_ARRAY_SIZE( \
189  SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ).Ready \
190  ) - 1, \
191  ( obj_name ) \
192  }
193 
194  /* Provided for backward compatibility */
195 
196  #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( name, prio_count ) \
197  RTEMS_SCHEDULER_PRIORITY_AFFINITY_SMP( name, prio_count )
198 
199  #define RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP( name, obj_name ) \
200  RTEMS_SCHEDULER_TABLE_PRIORITY_AFFINITY_SMP( name, obj_name )
201 #endif
202 
203 #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
205 
206  #define SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ) \
207  SCHEDULER_CONTEXT_NAME( priority_SMP_ ## name )
208 
209  #define RTEMS_SCHEDULER_PRIORITY_SMP( name, prio_count ) \
210  static struct { \
211  Scheduler_priority_SMP_Context Base; \
212  Chain_Control Ready[ ( prio_count ) ]; \
213  } SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name )
214 
215  #define RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( name, obj_name ) \
216  { \
217  &SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ).Base.Base.Base, \
218  SCHEDULER_PRIORITY_SMP_ENTRY_POINTS, \
219  RTEMS_ARRAY_SIZE( \
220  SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ).Ready \
221  ) - 1, \
222  ( obj_name ) \
223  }
224 
225  /* Provided for backward compatibility */
226 
227  #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP( name, prio_count ) \
228  RTEMS_SCHEDULER_PRIORITY_SMP( name, prio_count )
229 
230  #define RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP( name, obj_name ) \
231  RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( name, obj_name )
232 #endif
233 
234 #ifdef CONFIGURE_SCHEDULER_STRONG_APA
236 
237  #define SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) \
238  SCHEDULER_CONTEXT_NAME( strong_APA_ ## name )
239 
240  #define RTEMS_SCHEDULER_STRONG_APA( name, prio_count ) \
241  static struct { \
242  Scheduler_strong_APA_Context Base; \
243  Chain_Control Ready[ ( prio_count ) ]; \
244  } SCHEDULER_STRONG_APA_CONTEXT_NAME( name )
245 
246  #define RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name ) \
247  { \
248  &SCHEDULER_STRONG_APA_CONTEXT_NAME( name ).Base.Base.Base, \
249  SCHEDULER_STRONG_APA_ENTRY_POINTS, \
250  RTEMS_ARRAY_SIZE( \
251  SCHEDULER_STRONG_APA_CONTEXT_NAME( name ).Ready \
252  ) - 1, \
253  ( obj_name ) \
254  }
255 
256  /* Provided for backward compatibility */
257 
258  #define RTEMS_SCHEDULER_CONTEXT_STRONG_APA( name, prio_count ) \
259  RTEMS_SCHEDULER_STRONG_APA( name, prio_count )
260 
261  #define RTEMS_SCHEDULER_CONTROL_STRONG_APA( name, obj_name ) \
262  RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name )
263 #endif
264 
265 #ifdef CONFIGURE_SCHEDULER_SIMPLE
267 
268  #define SCHEDULER_SIMPLE_CONTEXT_NAME( name ) \
269  SCHEDULER_CONTEXT_NAME( simple_ ## name )
270 
271  #define RTEMS_SCHEDULER_SIMPLE( name ) \
272  static Scheduler_simple_Context \
273  SCHEDULER_SIMPLE_CONTEXT_NAME( name )
274 
275  #define RTEMS_SCHEDULER_TABLE_SIMPLE( name, obj_name ) \
276  { \
277  &SCHEDULER_SIMPLE_CONTEXT_NAME( name ).Base, \
278  SCHEDULER_SIMPLE_ENTRY_POINTS, \
279  SCHEDULER_SIMPLE_MAXIMUM_PRIORITY, \
280  ( obj_name ) \
281  }
282 
283  /* Provided for backward compatibility */
284 
285  #define RTEMS_SCHEDULER_CONTEXT_SIMPLE( name ) \
286  RTEMS_SCHEDULER_SIMPLE( name )
287 
288  #define RTEMS_SCHEDULER_CONTROL_SIMPLE( name, obj_name ) \
289  RTEMS_SCHEDULER_TABLE_SIMPLE( name, obj_name )
290 #endif
291 
292 #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
294 
295  #define SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ) \
296  SCHEDULER_CONTEXT_NAME( simple_SMP_ ## name )
297 
298  #define RTEMS_SCHEDULER_SIMPLE_SMP( name ) \
299  static Scheduler_simple_SMP_Context \
300  SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name )
301 
302  #define RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( name, obj_name ) \
303  { \
304  &SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ).Base.Base, \
305  SCHEDULER_SIMPLE_SMP_ENTRY_POINTS, \
306  SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY, \
307  ( obj_name ) \
308  }
309 
310  /* Provided for backward compatibility */
311 
312  #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP( name ) \
313  RTEMS_SCHEDULER_SIMPLE_SMP( name )
314 
315  #define RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP( name, obj_name ) \
316  RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( name, obj_name )
317 #endif
318 
319 #endif /* _RTEMS_SAPI_SCHEDULER_H */
Strong APA Scheduler API.
Thread Manipulation with the Priority-Based Scheduler.
Data Related to the Manipulation of Threads for the EDF Scheduler.
Simple SMP Scheduler API.
Deterministic Priority SMP Scheduler API.
Manipulation of Threads Simple-Priority-Based Ready Queue.
EDF SMP Scheduler API.
Scheduler control.
Definition: scheduler.h:266
Deterministic Priority Affinity SMP Scheduler API.
Constants and Structures Associated with the Scheduler.
Thread manipulation for the CBS scheduler.