1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief EDF SMP Scheduler API |
---|
5 | * |
---|
6 | * @ingroup ScoreSchedulerSMPEDF |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2017, 2018 embedded brains GmbH. |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_SCORE_SCHEDULEREDFSMP_H |
---|
18 | #define _RTEMS_SCORE_SCHEDULEREDFSMP_H |
---|
19 | |
---|
20 | #include <rtems/score/scheduler.h> |
---|
21 | #include <rtems/score/scheduleredf.h> |
---|
22 | #include <rtems/score/schedulersmp.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup ScoreSchedulerSMPEDF EDF Priority SMP Scheduler |
---|
30 | * |
---|
31 | * @ingroup ScoreSchedulerSMP |
---|
32 | * |
---|
33 | * @{ |
---|
34 | */ |
---|
35 | |
---|
36 | typedef struct { |
---|
37 | Scheduler_SMP_Node Base; |
---|
38 | |
---|
39 | /** |
---|
40 | * @brief Generation number to ensure FIFO/LIFO order for threads of the same |
---|
41 | * priority across different ready queues. |
---|
42 | */ |
---|
43 | int64_t generation; |
---|
44 | |
---|
45 | /** |
---|
46 | * @brief The ready queue index depending on the processor affinity and |
---|
47 | * pinning of the thread. |
---|
48 | * |
---|
49 | * The ready queue index zero is used for threads with a one-to-all thread |
---|
50 | * processor affinity. Threads with a one-to-one processor affinity use the |
---|
51 | * processor index plus one as the ready queue index. |
---|
52 | */ |
---|
53 | uint8_t ready_queue_index; |
---|
54 | |
---|
55 | /** |
---|
56 | * @brief Ready queue index according to thread affinity. |
---|
57 | */ |
---|
58 | uint8_t affinity_ready_queue_index; |
---|
59 | |
---|
60 | /** |
---|
61 | * @brief Ready queue index according to thread pinning. |
---|
62 | */ |
---|
63 | uint8_t pinning_ready_queue_index; |
---|
64 | } Scheduler_EDF_SMP_Node; |
---|
65 | |
---|
66 | typedef struct { |
---|
67 | /** |
---|
68 | * @brief Chain node for Scheduler_SMP_Context::Affine_queues. |
---|
69 | */ |
---|
70 | Chain_Node Node; |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief The ready threads of the corresponding affinity. |
---|
74 | */ |
---|
75 | RBTree_Control Queue; |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief The scheduled thread of the corresponding processor. |
---|
79 | */ |
---|
80 | Scheduler_EDF_SMP_Node *scheduled; |
---|
81 | } Scheduler_EDF_SMP_Ready_queue; |
---|
82 | |
---|
83 | typedef struct { |
---|
84 | Scheduler_SMP_Context Base; |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief Current generation for LIFO (index 0) and FIFO (index 1) ordering. |
---|
88 | */ |
---|
89 | int64_t generations[ 2 ]; |
---|
90 | |
---|
91 | /** |
---|
92 | * @brief Chain of ready queues with affine threads to determine the highest |
---|
93 | * priority ready thread. |
---|
94 | */ |
---|
95 | Chain_Control Affine_queues; |
---|
96 | |
---|
97 | /** |
---|
98 | * @brief A table with ready queues. |
---|
99 | * |
---|
100 | * The index zero queue is used for threads with a one-to-all processor |
---|
101 | * affinity. Index one corresponds to processor index zero, and so on. |
---|
102 | */ |
---|
103 | Scheduler_EDF_SMP_Ready_queue Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; |
---|
104 | } Scheduler_EDF_SMP_Context; |
---|
105 | |
---|
106 | #define SCHEDULER_EDF_SMP_ENTRY_POINTS \ |
---|
107 | { \ |
---|
108 | _Scheduler_EDF_SMP_Initialize, \ |
---|
109 | _Scheduler_default_Schedule, \ |
---|
110 | _Scheduler_EDF_SMP_Yield, \ |
---|
111 | _Scheduler_EDF_SMP_Block, \ |
---|
112 | _Scheduler_EDF_SMP_Unblock, \ |
---|
113 | _Scheduler_EDF_SMP_Update_priority, \ |
---|
114 | _Scheduler_EDF_Map_priority, \ |
---|
115 | _Scheduler_EDF_Unmap_priority, \ |
---|
116 | _Scheduler_EDF_SMP_Ask_for_help, \ |
---|
117 | _Scheduler_EDF_SMP_Reconsider_help_request, \ |
---|
118 | _Scheduler_EDF_SMP_Withdraw_node, \ |
---|
119 | _Scheduler_EDF_SMP_Pin, \ |
---|
120 | _Scheduler_EDF_SMP_Unpin, \ |
---|
121 | _Scheduler_EDF_SMP_Add_processor, \ |
---|
122 | _Scheduler_EDF_SMP_Remove_processor, \ |
---|
123 | _Scheduler_EDF_SMP_Node_initialize, \ |
---|
124 | _Scheduler_default_Node_destroy, \ |
---|
125 | _Scheduler_EDF_Release_job, \ |
---|
126 | _Scheduler_EDF_Cancel_job, \ |
---|
127 | _Scheduler_default_Tick, \ |
---|
128 | _Scheduler_EDF_SMP_Start_idle, \ |
---|
129 | _Scheduler_EDF_SMP_Set_affinity \ |
---|
130 | } |
---|
131 | |
---|
132 | void _Scheduler_EDF_SMP_Initialize( const Scheduler_Control *scheduler ); |
---|
133 | |
---|
134 | void _Scheduler_EDF_SMP_Node_initialize( |
---|
135 | const Scheduler_Control *scheduler, |
---|
136 | Scheduler_Node *node, |
---|
137 | Thread_Control *the_thread, |
---|
138 | Priority_Control priority |
---|
139 | ); |
---|
140 | |
---|
141 | void _Scheduler_EDF_SMP_Block( |
---|
142 | const Scheduler_Control *scheduler, |
---|
143 | Thread_Control *thread, |
---|
144 | Scheduler_Node *node |
---|
145 | ); |
---|
146 | |
---|
147 | void _Scheduler_EDF_SMP_Unblock( |
---|
148 | const Scheduler_Control *scheduler, |
---|
149 | Thread_Control *thread, |
---|
150 | Scheduler_Node *node |
---|
151 | ); |
---|
152 | |
---|
153 | void _Scheduler_EDF_SMP_Update_priority( |
---|
154 | const Scheduler_Control *scheduler, |
---|
155 | Thread_Control *the_thread, |
---|
156 | Scheduler_Node *node |
---|
157 | ); |
---|
158 | |
---|
159 | bool _Scheduler_EDF_SMP_Ask_for_help( |
---|
160 | const Scheduler_Control *scheduler, |
---|
161 | Thread_Control *the_thread, |
---|
162 | Scheduler_Node *node |
---|
163 | ); |
---|
164 | |
---|
165 | void _Scheduler_EDF_SMP_Reconsider_help_request( |
---|
166 | const Scheduler_Control *scheduler, |
---|
167 | Thread_Control *the_thread, |
---|
168 | Scheduler_Node *node |
---|
169 | ); |
---|
170 | |
---|
171 | void _Scheduler_EDF_SMP_Withdraw_node( |
---|
172 | const Scheduler_Control *scheduler, |
---|
173 | Thread_Control *the_thread, |
---|
174 | Scheduler_Node *node, |
---|
175 | Thread_Scheduler_state next_state |
---|
176 | ); |
---|
177 | |
---|
178 | void _Scheduler_EDF_SMP_Pin( |
---|
179 | const Scheduler_Control *scheduler, |
---|
180 | Thread_Control *the_thread, |
---|
181 | Scheduler_Node *node, |
---|
182 | struct Per_CPU_Control *cpu |
---|
183 | ); |
---|
184 | |
---|
185 | void _Scheduler_EDF_SMP_Unpin( |
---|
186 | const Scheduler_Control *scheduler, |
---|
187 | Thread_Control *the_thread, |
---|
188 | Scheduler_Node *node, |
---|
189 | struct Per_CPU_Control *cpu |
---|
190 | ); |
---|
191 | |
---|
192 | void _Scheduler_EDF_SMP_Add_processor( |
---|
193 | const Scheduler_Control *scheduler, |
---|
194 | Thread_Control *idle |
---|
195 | ); |
---|
196 | |
---|
197 | Thread_Control *_Scheduler_EDF_SMP_Remove_processor( |
---|
198 | const Scheduler_Control *scheduler, |
---|
199 | struct Per_CPU_Control *cpu |
---|
200 | ); |
---|
201 | |
---|
202 | void _Scheduler_EDF_SMP_Yield( |
---|
203 | const Scheduler_Control *scheduler, |
---|
204 | Thread_Control *thread, |
---|
205 | Scheduler_Node *node |
---|
206 | ); |
---|
207 | |
---|
208 | void _Scheduler_EDF_SMP_Start_idle( |
---|
209 | const Scheduler_Control *scheduler, |
---|
210 | Thread_Control *idle, |
---|
211 | struct Per_CPU_Control *cpu |
---|
212 | ); |
---|
213 | |
---|
214 | bool _Scheduler_EDF_SMP_Set_affinity( |
---|
215 | const Scheduler_Control *scheduler, |
---|
216 | Thread_Control *thread, |
---|
217 | Scheduler_Node *node, |
---|
218 | const Processor_mask *affinity |
---|
219 | ); |
---|
220 | |
---|
221 | /** @} */ |
---|
222 | |
---|
223 | #ifdef __cplusplus |
---|
224 | } |
---|
225 | #endif |
---|
226 | |
---|
227 | #endif /* _RTEMS_SCORE_SCHEDULEREDFSMP_H */ |
---|