1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSScoreSchedulerPriorityAffinitySMP |
---|
5 | * |
---|
6 | * @brief Deterministic Priority Affinity SMP Scheduler API |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 2014. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H |
---|
19 | #define _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H |
---|
20 | |
---|
21 | #include <rtems/score/scheduler.h> |
---|
22 | #include <rtems/score/schedulerpriority.h> |
---|
23 | #include <rtems/score/schedulersmp.h> |
---|
24 | #include <rtems/score/schedulerprioritysmp.h> |
---|
25 | |
---|
26 | #include <sys/cpuset.h> |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif /* __cplusplus */ |
---|
31 | |
---|
32 | /** |
---|
33 | * @defgroup RTEMSScoreSchedulerPriorityAffinitySMP Deterministic Priority Affinity SMP Scheduler |
---|
34 | * |
---|
35 | * @ingroup RTEMSScoreSchedulerPrioritySMP |
---|
36 | * |
---|
37 | * @brief Deterministic Priority Affinity SMP Scheduler |
---|
38 | * |
---|
39 | * This is an extension of the Deterministic Priority SMP Scheduler. which |
---|
40 | * is an implementation of the global fixed priority scheduler (G-FP). |
---|
41 | * It adds thread to core affinity support. |
---|
42 | * |
---|
43 | * @note This is the first iteration of this scheduler. It currently tracks |
---|
44 | * the requested affinity to exercise the Scheduler Framework but it |
---|
45 | * does not honor that affinity in assigning threads to cores. This |
---|
46 | * will be added in a subsequent revision. |
---|
47 | * @{ |
---|
48 | */ |
---|
49 | |
---|
50 | /** |
---|
51 | * @brief Entry points for the Deterministic Priority Affinity SMP Scheduler. |
---|
52 | */ |
---|
53 | #define SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS \ |
---|
54 | { \ |
---|
55 | _Scheduler_priority_SMP_Initialize, \ |
---|
56 | _Scheduler_default_Schedule, \ |
---|
57 | _Scheduler_priority_SMP_Yield, \ |
---|
58 | _Scheduler_priority_affinity_SMP_Block, \ |
---|
59 | _Scheduler_priority_affinity_SMP_Unblock, \ |
---|
60 | _Scheduler_priority_affinity_SMP_Update_priority, \ |
---|
61 | _Scheduler_default_Map_priority, \ |
---|
62 | _Scheduler_default_Unmap_priority, \ |
---|
63 | _Scheduler_priority_affinity_SMP_Ask_for_help, \ |
---|
64 | _Scheduler_priority_affinity_SMP_Reconsider_help_request, \ |
---|
65 | _Scheduler_priority_affinity_SMP_Withdraw_node, \ |
---|
66 | _Scheduler_default_Pin_or_unpin, \ |
---|
67 | _Scheduler_default_Pin_or_unpin, \ |
---|
68 | _Scheduler_priority_affinity_SMP_Add_processor, \ |
---|
69 | _Scheduler_priority_affinity_SMP_Remove_processor, \ |
---|
70 | _Scheduler_priority_affinity_SMP_Node_initialize, \ |
---|
71 | _Scheduler_default_Node_destroy, \ |
---|
72 | _Scheduler_default_Release_job, \ |
---|
73 | _Scheduler_default_Cancel_job, \ |
---|
74 | _Scheduler_default_Tick, \ |
---|
75 | _Scheduler_SMP_Start_idle, \ |
---|
76 | _Scheduler_priority_affinity_SMP_Set_affinity \ |
---|
77 | } |
---|
78 | |
---|
79 | /** |
---|
80 | * @brief Initializes per thread scheduler information. |
---|
81 | * |
---|
82 | * This routine allocates @a thread->scheduler. |
---|
83 | * |
---|
84 | * @param scheduler Points to the scheduler specific information. |
---|
85 | * @param[in, out] node The node the scheduler is allocating |
---|
86 | * management memory for. |
---|
87 | * @param the_thread The thread of the node. |
---|
88 | * @param priority The thread priority. |
---|
89 | */ |
---|
90 | void _Scheduler_priority_affinity_SMP_Node_initialize( |
---|
91 | const Scheduler_Control *scheduler, |
---|
92 | Scheduler_Node *node, |
---|
93 | Thread_Control *the_thread, |
---|
94 | Priority_Control priority |
---|
95 | ); |
---|
96 | |
---|
97 | /** |
---|
98 | * @brief Blocks a thread. |
---|
99 | * |
---|
100 | * @param scheduler The scheduler instance. |
---|
101 | * @param[in, out] The thread to block. |
---|
102 | * @param[in, out] node The scheduler node of the thread. |
---|
103 | */ |
---|
104 | void _Scheduler_priority_affinity_SMP_Block( |
---|
105 | const Scheduler_Control *scheduler, |
---|
106 | Thread_Control *thread, |
---|
107 | Scheduler_Node *node |
---|
108 | ); |
---|
109 | |
---|
110 | /** |
---|
111 | * @brief Unblocks a thread. |
---|
112 | * |
---|
113 | * @param scheduler The scheduler instance. |
---|
114 | * @param[in, out] The thread to unblock. |
---|
115 | * @param[in, out] node The scheduler node of the thread. |
---|
116 | */ |
---|
117 | void _Scheduler_priority_affinity_SMP_Unblock( |
---|
118 | const Scheduler_Control *scheduler, |
---|
119 | Thread_Control *thread, |
---|
120 | Scheduler_Node *node |
---|
121 | ); |
---|
122 | |
---|
123 | /** |
---|
124 | * @brief Updates the priority of the node. |
---|
125 | * |
---|
126 | * @param scheduler The scheduler instance. |
---|
127 | * @param the_thread The thread of the node. |
---|
128 | * @param[in, out] The node to update the priority of. |
---|
129 | */ |
---|
130 | void _Scheduler_priority_affinity_SMP_Update_priority( |
---|
131 | const Scheduler_Control *scheduler, |
---|
132 | Thread_Control *the_thread, |
---|
133 | Scheduler_Node *node |
---|
134 | ); |
---|
135 | |
---|
136 | /** |
---|
137 | * @brief Asks for help. |
---|
138 | * |
---|
139 | * @param scheduler The scheduler instance to ask for help. |
---|
140 | * @param the_thread The thread needing help. |
---|
141 | * @param node The scheduler node. |
---|
142 | * |
---|
143 | * @retval true Ask for help was successful. |
---|
144 | * @retval false Ask for help was not successful. |
---|
145 | */ |
---|
146 | bool _Scheduler_priority_affinity_SMP_Ask_for_help( |
---|
147 | const Scheduler_Control *scheduler, |
---|
148 | Thread_Control *the_thread, |
---|
149 | Scheduler_Node *node |
---|
150 | ); |
---|
151 | |
---|
152 | /** |
---|
153 | * @brief Reconsiders help. |
---|
154 | * |
---|
155 | * @param scheduler The scheduler instance to reconsider the help |
---|
156 | * request. |
---|
157 | * @param the_thread The thread reconsidering a help request. |
---|
158 | * @param node The scheduler node. |
---|
159 | */ |
---|
160 | void _Scheduler_priority_affinity_SMP_Reconsider_help_request( |
---|
161 | const Scheduler_Control *scheduler, |
---|
162 | Thread_Control *the_thread, |
---|
163 | Scheduler_Node *node |
---|
164 | ); |
---|
165 | |
---|
166 | /** |
---|
167 | * @brief Withdraws node. |
---|
168 | * |
---|
169 | * @param scheduler The scheduler instance to withdraw the node. |
---|
170 | * @param the_thread The thread using the node. |
---|
171 | * @param node The scheduler node to withdraw. |
---|
172 | * @param next_state The next thread scheduler state in the case the node is |
---|
173 | * scheduled. |
---|
174 | */ |
---|
175 | void _Scheduler_priority_affinity_SMP_Withdraw_node( |
---|
176 | const Scheduler_Control *scheduler, |
---|
177 | Thread_Control *the_thread, |
---|
178 | Scheduler_Node *node, |
---|
179 | Thread_Scheduler_state next_state |
---|
180 | ); |
---|
181 | |
---|
182 | /** |
---|
183 | * @brief Adds @a idle to @a scheduler. |
---|
184 | * |
---|
185 | * @param[in, out] scheduler The scheduler instance to add the processor to. |
---|
186 | * @param idle The idle thread control. |
---|
187 | */ |
---|
188 | void _Scheduler_priority_affinity_SMP_Add_processor( |
---|
189 | const Scheduler_Control *scheduler, |
---|
190 | Thread_Control *idle |
---|
191 | ); |
---|
192 | |
---|
193 | /** |
---|
194 | * @brief Removes an idle thread from the given cpu. |
---|
195 | * |
---|
196 | * @param scheduler The scheduler instance. |
---|
197 | * @param cpu The cpu control to remove from @a scheduler. |
---|
198 | * |
---|
199 | * @return The idle thread of the processor. |
---|
200 | */ |
---|
201 | Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor( |
---|
202 | const Scheduler_Control *scheduler, |
---|
203 | struct Per_CPU_Control *cpu |
---|
204 | ); |
---|
205 | |
---|
206 | /** |
---|
207 | * @brief Sets affinity for the priority affinity SMP scheduler. |
---|
208 | * |
---|
209 | * @param scheduler The scheduler of the thread. |
---|
210 | * @param[in, out] thread The associated thread. |
---|
211 | * @param[in, out] node The scheduler node. |
---|
212 | * @param affinity The new affinity set. |
---|
213 | * |
---|
214 | * @retval true if successful |
---|
215 | * @retval false if unsuccessful |
---|
216 | */ |
---|
217 | bool _Scheduler_priority_affinity_SMP_Set_affinity( |
---|
218 | const Scheduler_Control *scheduler, |
---|
219 | Thread_Control *thread, |
---|
220 | Scheduler_Node *node, |
---|
221 | const Processor_mask *affinity |
---|
222 | ); |
---|
223 | |
---|
224 | /** |
---|
225 | * @brief Scheduler node specialization for Deterministic Priority Affinity SMP |
---|
226 | * schedulers. |
---|
227 | * |
---|
228 | * This is a per thread structure. |
---|
229 | */ |
---|
230 | typedef struct { |
---|
231 | /** |
---|
232 | * @brief SMP priority scheduler node. |
---|
233 | */ |
---|
234 | Scheduler_priority_SMP_Node Base; |
---|
235 | |
---|
236 | /** |
---|
237 | * @brief The thread processor affinity set. |
---|
238 | */ |
---|
239 | Processor_mask Affinity; |
---|
240 | } Scheduler_priority_affinity_SMP_Node; |
---|
241 | |
---|
242 | /** @} */ |
---|
243 | |
---|
244 | #ifdef __cplusplus |
---|
245 | } |
---|
246 | #endif /* __cplusplus */ |
---|
247 | |
---|
248 | #endif /* _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H */ |
---|