source: rtems/cpukit/score/src/schedulerprioritysmp.c @ 0e754fac

5
Last change on this file since 0e754fac was 0e754fac, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 21, 2016 at 12:41:19 PM

score: Delete unused scheduler ask for help X op

  • Property mode set to 100644
File size: 8.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSchedulerPrioritySMP
5 *
6 * @brief Deterministic Priority SMP Scheduler Implementation
7 */
8
9/*
10 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#if HAVE_CONFIG_H
24  #include "config.h"
25#endif
26
27#include <rtems/score/schedulerprioritysmpimpl.h>
28
29static Scheduler_priority_SMP_Context *
30_Scheduler_priority_SMP_Get_context( const Scheduler_Control *scheduler )
31{
32  return (Scheduler_priority_SMP_Context *) _Scheduler_Get_context( scheduler );
33}
34
35void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler )
36{
37  Scheduler_priority_SMP_Context *self =
38    _Scheduler_priority_SMP_Get_context( scheduler );
39
40  _Scheduler_SMP_Initialize( &self->Base );
41  _Priority_bit_map_Initialize( &self->Bit_map );
42  _Scheduler_priority_Ready_queue_initialize(
43    &self->Ready[ 0 ],
44    scheduler->maximum_priority
45  );
46}
47
48void _Scheduler_priority_SMP_Node_initialize(
49  const Scheduler_Control *scheduler,
50  Scheduler_Node          *node,
51  Thread_Control          *the_thread,
52  Priority_Control         priority
53)
54{
55  Scheduler_Context              *context;
56  Scheduler_priority_SMP_Context *self;
57  Scheduler_priority_SMP_Node    *the_node;
58
59  the_node = _Scheduler_priority_SMP_Node_downcast( node );
60  _Scheduler_SMP_Node_initialize(
61    scheduler,
62    &the_node->Base,
63    the_thread,
64    priority
65  );
66
67  context = _Scheduler_Get_context( scheduler );
68  self = _Scheduler_priority_SMP_Get_self( context );
69  _Scheduler_priority_Ready_queue_update(
70    &the_node->Ready_queue,
71    priority,
72    &self->Bit_map,
73    &self->Ready[ 0 ]
74  );
75}
76
77static Scheduler_Node *_Scheduler_priority_SMP_Get_highest_ready(
78  Scheduler_Context *context,
79  Scheduler_Node    *node
80)
81{
82  Scheduler_priority_SMP_Context *self =
83    _Scheduler_priority_SMP_Get_self( context );
84
85  (void) node;
86
87  return (Scheduler_Node *) _Scheduler_priority_Ready_queue_first(
88    &self->Bit_map,
89    &self->Ready[ 0 ]
90  );
91}
92
93void _Scheduler_priority_SMP_Block(
94  const Scheduler_Control *scheduler,
95  Thread_Control          *thread,
96  Scheduler_Node          *node
97)
98{
99  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
100
101  _Scheduler_SMP_Block(
102    context,
103    thread,
104    node,
105    _Scheduler_priority_SMP_Extract_from_ready,
106    _Scheduler_priority_SMP_Get_highest_ready,
107    _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
108    _Scheduler_SMP_Allocate_processor_lazy
109  );
110}
111
112static Thread_Control *_Scheduler_priority_SMP_Enqueue_ordered(
113  Scheduler_Context    *context,
114  Scheduler_Node       *node,
115  Thread_Control       *needs_help,
116  Chain_Node_order      order,
117  Scheduler_SMP_Insert  insert_ready,
118  Scheduler_SMP_Insert  insert_scheduled
119)
120{
121  return _Scheduler_SMP_Enqueue_ordered(
122    context,
123    node,
124    needs_help,
125    order,
126    insert_ready,
127    insert_scheduled,
128    _Scheduler_priority_SMP_Move_from_scheduled_to_ready,
129    _Scheduler_SMP_Get_lowest_scheduled,
130    _Scheduler_SMP_Allocate_processor_lazy
131  );
132}
133
134static Thread_Control *_Scheduler_priority_SMP_Enqueue_lifo(
135  Scheduler_Context *context,
136  Scheduler_Node    *node,
137  Thread_Control    *needs_help
138)
139{
140  return _Scheduler_priority_SMP_Enqueue_ordered(
141    context,
142    node,
143    needs_help,
144    _Scheduler_SMP_Insert_priority_lifo_order,
145    _Scheduler_priority_SMP_Insert_ready_lifo,
146    _Scheduler_SMP_Insert_scheduled_lifo
147  );
148}
149
150static Thread_Control *_Scheduler_priority_SMP_Enqueue_fifo(
151  Scheduler_Context *context,
152  Scheduler_Node    *node,
153  Thread_Control    *needs_help
154)
155{
156  return _Scheduler_priority_SMP_Enqueue_ordered(
157    context,
158    node,
159    needs_help,
160    _Scheduler_SMP_Insert_priority_fifo_order,
161    _Scheduler_priority_SMP_Insert_ready_fifo,
162    _Scheduler_SMP_Insert_scheduled_fifo
163  );
164}
165
166static Thread_Control *_Scheduler_priority_SMP_Enqueue_scheduled_ordered(
167  Scheduler_Context *context,
168  Scheduler_Node *node,
169  Chain_Node_order order,
170  Scheduler_SMP_Insert insert_ready,
171  Scheduler_SMP_Insert insert_scheduled
172)
173{
174  return _Scheduler_SMP_Enqueue_scheduled_ordered(
175    context,
176    node,
177    order,
178    _Scheduler_priority_SMP_Extract_from_ready,
179    _Scheduler_priority_SMP_Get_highest_ready,
180    insert_ready,
181    insert_scheduled,
182    _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
183    _Scheduler_SMP_Allocate_processor_lazy
184  );
185}
186
187static Thread_Control *_Scheduler_priority_SMP_Enqueue_scheduled_lifo(
188  Scheduler_Context *context,
189  Scheduler_Node *node
190)
191{
192  return _Scheduler_priority_SMP_Enqueue_scheduled_ordered(
193    context,
194    node,
195    _Scheduler_SMP_Insert_priority_lifo_order,
196    _Scheduler_priority_SMP_Insert_ready_lifo,
197    _Scheduler_SMP_Insert_scheduled_lifo
198  );
199}
200
201static Thread_Control *_Scheduler_priority_SMP_Enqueue_scheduled_fifo(
202  Scheduler_Context *context,
203  Scheduler_Node *node
204)
205{
206  return _Scheduler_priority_SMP_Enqueue_scheduled_ordered(
207    context,
208    node,
209    _Scheduler_SMP_Insert_priority_fifo_order,
210    _Scheduler_priority_SMP_Insert_ready_fifo,
211    _Scheduler_SMP_Insert_scheduled_fifo
212  );
213}
214
215Thread_Control *_Scheduler_priority_SMP_Unblock(
216  const Scheduler_Control *scheduler,
217  Thread_Control          *thread,
218  Scheduler_Node          *node
219)
220{
221  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
222
223  return _Scheduler_SMP_Unblock(
224    context,
225    thread,
226    node,
227    _Scheduler_priority_SMP_Do_update,
228    _Scheduler_priority_SMP_Enqueue_fifo
229  );
230}
231
232static bool _Scheduler_priority_SMP_Do_ask_for_help(
233  Scheduler_Context *context,
234  Thread_Control    *the_thread,
235  Scheduler_Node    *node
236)
237{
238  return _Scheduler_SMP_Ask_for_help(
239    context,
240    the_thread,
241    node,
242    _Scheduler_SMP_Insert_priority_lifo_order,
243    _Scheduler_priority_SMP_Insert_ready_lifo,
244    _Scheduler_SMP_Insert_scheduled_lifo,
245    _Scheduler_priority_SMP_Move_from_scheduled_to_ready,
246    _Scheduler_SMP_Get_lowest_scheduled,
247    _Scheduler_SMP_Allocate_processor_lazy
248  );
249}
250
251void _Scheduler_priority_SMP_Update_priority(
252  const Scheduler_Control *scheduler,
253  Thread_Control          *thread,
254  Scheduler_Node          *node
255)
256{
257  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
258
259  _Scheduler_SMP_Update_priority(
260    context,
261    thread,
262    node,
263    _Scheduler_priority_SMP_Extract_from_ready,
264    _Scheduler_priority_SMP_Do_update,
265    _Scheduler_priority_SMP_Enqueue_fifo,
266    _Scheduler_priority_SMP_Enqueue_lifo,
267    _Scheduler_priority_SMP_Enqueue_scheduled_fifo,
268    _Scheduler_priority_SMP_Enqueue_scheduled_lifo,
269    _Scheduler_priority_SMP_Do_ask_for_help
270  );
271}
272
273bool _Scheduler_priority_SMP_Ask_for_help(
274  const Scheduler_Control *scheduler,
275  Thread_Control          *the_thread,
276  Scheduler_Node          *node
277)
278{
279  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
280
281  return _Scheduler_priority_SMP_Do_ask_for_help( context, the_thread, node );
282}
283
284void _Scheduler_priority_SMP_Reconsider_help_request(
285  const Scheduler_Control *scheduler,
286  Thread_Control          *the_thread,
287  Scheduler_Node          *node
288)
289{
290  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
291
292  _Scheduler_SMP_Reconsider_help_request(
293    context,
294    the_thread,
295    node,
296    _Scheduler_priority_SMP_Extract_from_ready
297  );
298}
299
300void _Scheduler_priority_SMP_Withdraw_node(
301  const Scheduler_Control *scheduler,
302  Thread_Control          *the_thread,
303  Scheduler_Node          *node,
304  Thread_Scheduler_state   next_state
305)
306{
307  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
308
309  _Scheduler_SMP_Withdraw_node(
310    context,
311    the_thread,
312    node,
313    next_state,
314    _Scheduler_priority_SMP_Extract_from_ready,
315    _Scheduler_priority_SMP_Get_highest_ready,
316    _Scheduler_priority_SMP_Move_from_ready_to_scheduled,
317    _Scheduler_SMP_Allocate_processor_lazy
318  );
319}
320
321Thread_Control *_Scheduler_priority_SMP_Yield(
322  const Scheduler_Control *scheduler,
323  Thread_Control          *thread,
324  Scheduler_Node          *node
325)
326{
327  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
328
329  return _Scheduler_SMP_Yield(
330    context,
331    thread,
332    node,
333    _Scheduler_priority_SMP_Extract_from_ready,
334    _Scheduler_priority_SMP_Enqueue_fifo,
335    _Scheduler_priority_SMP_Enqueue_scheduled_fifo
336  );
337}
Note: See TracBrowser for help on using the repository browser.