Scheduler Strong APA  Release
schedulerstrongapa.h
Go to the documentation of this file.
1 
9 /* SPDX-License-Identifier: BSD-2-Clause
10  *
11  * Copyright (C) 2020 Richi Dubey
12  * Copyright (c) 2013, 2018 embedded brains GmbH
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _RTEMS_SCORE_SCHEDULERSTRONGAPA_H
37 #define _RTEMS_SCORE_SCHEDULERSTRONGAPA_H
38 
39 #include <rtems/score/scheduler.h>
40 #include <rtems/score/schedulersmp.h>
41 #include <rtems/score/percpu.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 #define STRONG_SCHEDULER_NODE_OF_CHAIN( node ) \
48  RTEMS_CONTAINER_OF( node, Scheduler_strong_APA_Node, Ready_node )
49 
73 typedef struct {
77  Scheduler_SMP_Node Base;
78 
82  Chain_Node Ready_node;
83 
89  Per_CPU_Control *cpu_to_preempt;
90 
94  Processor_mask Affinity;
96 
97 
101 typedef struct
102 {
106  Per_CPU_Control *cpu;
107 
111  Scheduler_Node *preempting_node;
112 
117  bool visited;
118 
122  Scheduler_Node *executing;
124 
128 typedef struct {
132  Scheduler_SMP_Context Base;
133 
138  Chain_Control Ready;
139 
143  Scheduler_strong_APA_CPU CPU[ RTEMS_ZERO_LENGTH_ARRAY ];
145 
146 #define SCHEDULER_STRONG_APA_MAXIMUM_PRIORITY 255
147 
151 #define SCHEDULER_STRONG_APA_ENTRY_POINTS \
152  { \
153  _Scheduler_strong_APA_Initialize, \
154  _Scheduler_default_Schedule, \
155  _Scheduler_strong_APA_Yield, \
156  _Scheduler_strong_APA_Block, \
157  _Scheduler_strong_APA_Unblock, \
158  _Scheduler_strong_APA_Update_priority, \
159  _Scheduler_default_Map_priority, \
160  _Scheduler_default_Unmap_priority, \
161  _Scheduler_strong_APA_Ask_for_help, \
162  _Scheduler_strong_APA_Reconsider_help_request, \
163  _Scheduler_strong_APA_Withdraw_node, \
164  _Scheduler_default_Pin_or_unpin, \
165  _Scheduler_default_Pin_or_unpin, \
166  _Scheduler_strong_APA_Add_processor, \
167  _Scheduler_strong_APA_Remove_processor, \
168  _Scheduler_strong_APA_Node_initialize, \
169  _Scheduler_default_Node_destroy, \
170  _Scheduler_default_Release_job, \
171  _Scheduler_default_Cancel_job, \
172  _Scheduler_default_Tick, \
173  _Scheduler_strong_APA_Start_idle, \
174  _Scheduler_strong_APA_Set_affinity \
175  }
176 
182 void _Scheduler_strong_APA_Initialize( const Scheduler_Control *scheduler );
183 
193  const Scheduler_Control *scheduler,
194  Scheduler_Node *node,
195  Thread_Control *the_thread,
196  Priority_Control priority
197 );
198 
207  const Scheduler_Control *scheduler,
208  Thread_Control *the_thread,
209  Scheduler_Node *node
210 );
211 
220  const Scheduler_Control *scheduler,
221  Thread_Control *the_thread,
222  Scheduler_Node *node
223 );
224 
233  const Scheduler_Control *scheduler,
234  Thread_Control *the_thread,
235  Scheduler_Node *node
236 );
237 
249  const Scheduler_Control *scheduler,
250  Thread_Control *the_thread,
251  Scheduler_Node *node
252 );
253 
262  const Scheduler_Control *scheduler,
263  Thread_Control *the_thread,
264  Scheduler_Node *node
265 );
266 
276  const Scheduler_Control *scheduler,
277  Thread_Control *the_thread,
278  Scheduler_Node *node,
279  Thread_Scheduler_state next_state
280 );
281 
289  const Scheduler_Control *scheduler,
290  Thread_Control *idle
291 );
292 
302  const Scheduler_Control *scheduler,
303  struct Per_CPU_Control *cpu
304 );
305 
314  const Scheduler_Control *scheduler,
315  Thread_Control *the_thread,
316  Scheduler_Node *node
317 );
318 
327  const Scheduler_Control *scheduler,
328  Thread_Control *idle,
329  struct Per_CPU_Control *cpu
330 );
331 
340  const Scheduler_Control *scheduler,
341  Thread_Control *thread,
342  Scheduler_Node *node_base,
343  const Processor_mask *affinity
344 );
345 
348 #ifdef __cplusplus
349 }
350 #endif /* __cplusplus */
351 
352 #endif /* _RTEMS_SCORE_SCHEDULERSTRONGAPA_H */
Per_CPU_Control * cpu
CPU in a queue.
Scheduler_Node * preempting_node
The node that would preempt this CPU.
Chain_Control Ready
Chain of all the ready and scheduled nodes present in the Strong APA scheduler.
void _Scheduler_strong_APA_Add_processor(const Scheduler_Control *scheduler, Thread_Control *idle)
Adds the idle thread to a processor.
Chain_Node Ready_node
Chain node for Scheduler_strong_APA_Context::Ready.
CPU related variables and a CPU_Control to implement BFS.
bool _Scheduler_strong_APA_Ask_for_help(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Asks for help.
void _Scheduler_strong_APA_Node_initialize(const Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority)
Initializes the node with the given priority.
bool visited
Whether or not this cpu has been added to the queue (visited in BFS).
Scheduler_SMP_Node Base
SMP scheduler node.
Thread_Control * _Scheduler_strong_APA_Remove_processor(const Scheduler_Control *scheduler, struct Per_CPU_Control *cpu)
Removes an idle thread from the given cpu.
void _Scheduler_strong_APA_Withdraw_node(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node, Thread_Scheduler_state next_state)
Withdraws the node.
Per_CPU_Control * cpu_to_preempt
CPU that this node would preempt in the backtracking part of _Scheduler_strong_APA_Get_highest_ready ...
Scheduler_Node * executing
The node currently executing on this cpu.
void _Scheduler_strong_APA_Start_idle(const Scheduler_Control *scheduler, Thread_Control *idle, struct Per_CPU_Control *cpu)
Starts an idle thread.
Scheduler context and node definition for Strong APA scheduler.
void _Scheduler_strong_APA_Update_priority(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Updates the priority of the node.
Processor_mask Affinity
The associated affinity set of this node.
Scheduler node specialization for Strong APA schedulers.
void _Scheduler_strong_APA_Block(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Blocks the thread.
void _Scheduler_strong_APA_Initialize(const Scheduler_Control *scheduler)
Initializes the scheduler.
bool _Scheduler_strong_APA_Set_affinity(const Scheduler_Control *scheduler, Thread_Control *thread, Scheduler_Node *node_base, const Processor_mask *affinity)
Sets the affinity .
void _Scheduler_strong_APA_Unblock(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Unblocks the thread.
void _Scheduler_strong_APA_Reconsider_help_request(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Reconsiders help request.
void _Scheduler_strong_APA_Yield(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Performs a yield operation.