1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSScoreSchedulerSMPSimple |
---|
5 | * |
---|
6 | * @brief Simple SMP Scheduler API |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * Copyright (c) 2013, 2018 embedded brains GmbH. |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H |
---|
20 | #define _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <rtems/score/scheduler.h> |
---|
27 | #include <rtems/score/schedulerpriority.h> |
---|
28 | #include <rtems/score/schedulersmp.h> |
---|
29 | |
---|
30 | /** |
---|
31 | * @defgroup RTEMSScoreSchedulerSMPSimple Simple Priority SMP Scheduler |
---|
32 | * |
---|
33 | * @ingroup RTEMSScoreSchedulerSMP |
---|
34 | * |
---|
35 | * @brief Simple Priority SMP Scheduler |
---|
36 | * |
---|
37 | * The Simple Priority SMP Scheduler allocates a processor for the processor |
---|
38 | * count highest priority ready threads. The thread priority and position in |
---|
39 | * the ready chain are the only information to determine the scheduling |
---|
40 | * decision. Threads with an allocated processor are in the scheduled chain. |
---|
41 | * After initialization the scheduled chain has exactly processor count nodes. |
---|
42 | * Each processor has exactly one allocated thread after initialization. All |
---|
43 | * enqueue and extract operations may exchange threads with the scheduled |
---|
44 | * chain. One thread will be added and another will be removed. The scheduled |
---|
45 | * and ready chain is ordered according to the thread priority order. The |
---|
46 | * chain insert operations are O(count of ready threads), thus this scheduler |
---|
47 | * is unsuitable for most real-time applications. |
---|
48 | * |
---|
49 | * The thread preempt mode will be ignored. |
---|
50 | * |
---|
51 | * @{ |
---|
52 | */ |
---|
53 | |
---|
54 | typedef struct { |
---|
55 | Scheduler_SMP_Context Base; |
---|
56 | Chain_Control Ready; |
---|
57 | } Scheduler_simple_SMP_Context; |
---|
58 | |
---|
59 | #define SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY 255 |
---|
60 | |
---|
61 | /** |
---|
62 | * @brief Entry points for the Simple SMP Scheduler. |
---|
63 | */ |
---|
64 | #define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \ |
---|
65 | { \ |
---|
66 | _Scheduler_simple_SMP_Initialize, \ |
---|
67 | _Scheduler_default_Schedule, \ |
---|
68 | _Scheduler_simple_SMP_Yield, \ |
---|
69 | _Scheduler_simple_SMP_Block, \ |
---|
70 | _Scheduler_simple_SMP_Unblock, \ |
---|
71 | _Scheduler_simple_SMP_Update_priority, \ |
---|
72 | _Scheduler_default_Map_priority, \ |
---|
73 | _Scheduler_default_Unmap_priority, \ |
---|
74 | _Scheduler_simple_SMP_Ask_for_help, \ |
---|
75 | _Scheduler_simple_SMP_Reconsider_help_request, \ |
---|
76 | _Scheduler_simple_SMP_Withdraw_node, \ |
---|
77 | _Scheduler_default_Pin_or_unpin, \ |
---|
78 | _Scheduler_default_Pin_or_unpin, \ |
---|
79 | _Scheduler_simple_SMP_Add_processor, \ |
---|
80 | _Scheduler_simple_SMP_Remove_processor, \ |
---|
81 | _Scheduler_simple_SMP_Node_initialize, \ |
---|
82 | _Scheduler_default_Node_destroy, \ |
---|
83 | _Scheduler_default_Release_job, \ |
---|
84 | _Scheduler_default_Cancel_job, \ |
---|
85 | _Scheduler_default_Tick, \ |
---|
86 | _Scheduler_SMP_Start_idle \ |
---|
87 | SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief Initializes the scheduler's context. |
---|
92 | * |
---|
93 | * @param scheduler The scheduler instance to initialize the context of. |
---|
94 | */ |
---|
95 | void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler ); |
---|
96 | |
---|
97 | /** |
---|
98 | * @brief Initializes the node with the given attributes. |
---|
99 | * |
---|
100 | * @param scheduler The scheduler instance. |
---|
101 | * @param[out] node The node to initialize. |
---|
102 | * @param the_thread The user of the node, if RTEMS_SMP is defined. |
---|
103 | * @param priority The priority of the node to initialize. |
---|
104 | */ |
---|
105 | void _Scheduler_simple_SMP_Node_initialize( |
---|
106 | const Scheduler_Control *scheduler, |
---|
107 | Scheduler_Node *node, |
---|
108 | Thread_Control *the_thread, |
---|
109 | Priority_Control priority |
---|
110 | ); |
---|
111 | |
---|
112 | /** |
---|
113 | * @brief Blocks a thread. |
---|
114 | * |
---|
115 | * @param scheduler The scheduler instance. |
---|
116 | * @param[in, out] thread The thread to block. |
---|
117 | * @param[in, out] node The scheduler node of @a thread. |
---|
118 | */ |
---|
119 | void _Scheduler_simple_SMP_Block( |
---|
120 | const Scheduler_Control *scheduler, |
---|
121 | Thread_Control *thread, |
---|
122 | Scheduler_Node *node |
---|
123 | ); |
---|
124 | |
---|
125 | /** |
---|
126 | * @brief Unblocks a thread. |
---|
127 | * |
---|
128 | * @param scheduler The scheduler instance. |
---|
129 | * @param[in, out] thread The thread to unblock. |
---|
130 | * @param[in, out] node The scheduler node of @a thread. |
---|
131 | */ |
---|
132 | void _Scheduler_simple_SMP_Unblock( |
---|
133 | const Scheduler_Control *scheduler, |
---|
134 | Thread_Control *thread, |
---|
135 | Scheduler_Node *node |
---|
136 | ); |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief Updates the priority of the node. |
---|
140 | * |
---|
141 | * @param scheduler The scheduler instance. |
---|
142 | * @param the_thread The thread of @a node. |
---|
143 | * @param node The node to update the priority of. |
---|
144 | */ |
---|
145 | void _Scheduler_simple_SMP_Update_priority( |
---|
146 | const Scheduler_Control *scheduler, |
---|
147 | Thread_Control *the_thread, |
---|
148 | Scheduler_Node *node |
---|
149 | ); |
---|
150 | |
---|
151 | /** |
---|
152 | * @brief Asks for help. |
---|
153 | * |
---|
154 | * @param scheduler The scheduler instance to ask for help. |
---|
155 | * @param the_thread The thread needing help. |
---|
156 | * @param node The scheduler node. |
---|
157 | * |
---|
158 | * @retval true Ask for help was successful. |
---|
159 | * @retval false Ask for help was not successful. |
---|
160 | */ |
---|
161 | bool _Scheduler_simple_SMP_Ask_for_help( |
---|
162 | const Scheduler_Control *scheduler, |
---|
163 | Thread_Control *the_thread, |
---|
164 | Scheduler_Node *node |
---|
165 | ); |
---|
166 | |
---|
167 | /** |
---|
168 | * @brief Reconsiders help. |
---|
169 | * |
---|
170 | * @param scheduler The scheduler instance to reconsider the help |
---|
171 | * request. |
---|
172 | * @param the_thread The thread reconsidering a help request. |
---|
173 | * @param node The scheduler node. |
---|
174 | */ |
---|
175 | void _Scheduler_simple_SMP_Reconsider_help_request( |
---|
176 | const Scheduler_Control *scheduler, |
---|
177 | Thread_Control *the_thread, |
---|
178 | Scheduler_Node *node |
---|
179 | ); |
---|
180 | |
---|
181 | /** |
---|
182 | * @brief Withdraws node. |
---|
183 | * |
---|
184 | * @param scheduler The scheduler instance to withdraw the node. |
---|
185 | * @param the_thread The thread using the node. |
---|
186 | * @param node The scheduler node to withdraw. |
---|
187 | * @param next_state The next thread scheduler state in the case the node is |
---|
188 | * scheduled. |
---|
189 | */ |
---|
190 | void _Scheduler_simple_SMP_Withdraw_node( |
---|
191 | const Scheduler_Control *scheduler, |
---|
192 | Thread_Control *the_thread, |
---|
193 | Scheduler_Node *node, |
---|
194 | Thread_Scheduler_state next_state |
---|
195 | ); |
---|
196 | |
---|
197 | /** |
---|
198 | * @brief Adds @a idle to @a scheduler. |
---|
199 | * |
---|
200 | * @param[in, out] scheduler The scheduler instance to add the processor to. |
---|
201 | * @param idle The idle thread control. |
---|
202 | */ |
---|
203 | void _Scheduler_simple_SMP_Add_processor( |
---|
204 | const Scheduler_Control *scheduler, |
---|
205 | Thread_Control *idle |
---|
206 | ); |
---|
207 | |
---|
208 | /** |
---|
209 | * @brief Removes an idle thread from the given cpu. |
---|
210 | * |
---|
211 | * @param scheduler The scheduler instance. |
---|
212 | * @param cpu The cpu control to remove from @a scheduler. |
---|
213 | * |
---|
214 | * @return The idle thread of the processor. |
---|
215 | */ |
---|
216 | Thread_Control *_Scheduler_simple_SMP_Remove_processor( |
---|
217 | const Scheduler_Control *scheduler, |
---|
218 | struct Per_CPU_Control *cpu |
---|
219 | ); |
---|
220 | |
---|
221 | /** |
---|
222 | * Performs a yield operation for the thread. |
---|
223 | * |
---|
224 | * @param scheduler The scheduler instance. |
---|
225 | * @param thread The thread to yield. |
---|
226 | * @param[in, out] node The node of the thread to perform a yield. |
---|
227 | */ |
---|
228 | void _Scheduler_simple_SMP_Yield( |
---|
229 | const Scheduler_Control *scheduler, |
---|
230 | Thread_Control *thread, |
---|
231 | Scheduler_Node *node |
---|
232 | ); |
---|
233 | |
---|
234 | /** @} */ |
---|
235 | |
---|
236 | #ifdef __cplusplus |
---|
237 | } |
---|
238 | #endif |
---|
239 | |
---|
240 | #endif |
---|
241 | /* end of include file */ |
---|