RTEMS 6.1-rc2
Loading...
Searching...
No Matches
schedulerprioritysmpimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
13/*
14 * Copyright (C) 2013, 2017 embedded brains GmbH & Co. KG
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H
39#define _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H
40
45
46#ifdef __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49
55static inline Scheduler_priority_SMP_Context *_Scheduler_priority_SMP_Get_self(
57)
58{
60}
61
62static inline Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Thread_get_node(
63 Thread_Control *thread
64)
65{
66 return (Scheduler_priority_SMP_Node *) _Thread_Scheduler_get_home_node( thread );
67}
68
69static inline Scheduler_priority_SMP_Node *
70_Scheduler_priority_SMP_Node_downcast( Scheduler_Node *node )
71{
72 return (Scheduler_priority_SMP_Node *) node;
73}
74
75static inline bool _Scheduler_priority_SMP_Has_ready( Scheduler_Context *context )
76{
78 _Scheduler_priority_SMP_Get_self( context );
79
80 return !_Priority_bit_map_Is_empty( &self->Bit_map );
81}
82
83static inline void _Scheduler_priority_SMP_Move_from_scheduled_to_ready(
85 Scheduler_Node *scheduled_to_ready
86)
87{
89 _Scheduler_priority_SMP_Get_self( context );
91 _Scheduler_priority_SMP_Node_downcast( scheduled_to_ready );
92
93 _Chain_Extract_unprotected( &node->Base.Base.Node.Chain );
94 _Scheduler_priority_Ready_queue_enqueue_first(
95 &node->Base.Base.Node.Chain,
96 &node->Ready_queue,
97 &self->Bit_map
98 );
99}
100
101static inline void _Scheduler_priority_SMP_Move_from_ready_to_scheduled(
103 Scheduler_Node *ready_to_scheduled
104)
105{
108 Priority_Control insert_priority;
109
110 self = _Scheduler_priority_SMP_Get_self( context );
111 node = _Scheduler_priority_SMP_Node_downcast( ready_to_scheduled );
112
113 _Scheduler_priority_Ready_queue_extract(
114 &node->Base.Base.Node.Chain,
115 &node->Ready_queue,
116 &self->Bit_map
117 );
118 insert_priority = _Scheduler_SMP_Node_priority( &node->Base.Base );
119 insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority );
120 _Chain_Insert_ordered_unprotected(
121 &self->Base.Scheduled,
122 &node->Base.Base.Node.Chain,
123 &insert_priority,
124 _Scheduler_SMP_Priority_less_equal
125 );
126}
127
128static inline void _Scheduler_priority_SMP_Insert_ready(
130 Scheduler_Node *node_base,
131 Priority_Control insert_priority
132)
133{
136
137 self = _Scheduler_priority_SMP_Get_self( context );
138 node = _Scheduler_priority_SMP_Node_downcast( node_base );
139
140 if ( SCHEDULER_PRIORITY_IS_APPEND( insert_priority ) ) {
141 _Scheduler_priority_Ready_queue_enqueue(
142 &node->Base.Base.Node.Chain,
143 &node->Ready_queue,
144 &self->Bit_map
145 );
146 } else {
147 _Scheduler_priority_Ready_queue_enqueue_first(
148 &node->Base.Base.Node.Chain,
149 &node->Ready_queue,
150 &self->Bit_map
151 );
152 }
153}
154
155static inline void _Scheduler_priority_SMP_Extract_from_ready(
157 Scheduler_Node *thread
158)
159{
161 _Scheduler_priority_SMP_Get_self( context );
163 _Scheduler_priority_SMP_Node_downcast( thread );
164
165 _Scheduler_priority_Ready_queue_extract(
166 &node->Base.Base.Node.Chain,
167 &node->Ready_queue,
168 &self->Bit_map
169 );
170}
171
172static inline Scheduler_Node *_Scheduler_priority_SMP_Get_idle( void *arg )
173{
175 Scheduler_priority_SMP_Node *lowest_ready;
176
177 self = _Scheduler_priority_SMP_Get_self( arg );
178 lowest_ready = (Scheduler_priority_SMP_Node *)
179 _Chain_Last( self->idle_ready_queue );
180 _Scheduler_priority_Ready_queue_extract(
181 &lowest_ready->Base.Base.Node.Chain,
182 &lowest_ready->Ready_queue,
183 &self->Bit_map
184 );
185
186 return &lowest_ready->Base.Base;
187}
188
189static inline void _Scheduler_priority_SMP_Release_idle(
190 Scheduler_Node *node_base,
191 void *arg
192)
193{
196
197 self = _Scheduler_priority_SMP_Get_self( arg );
198 node = _Scheduler_priority_SMP_Node_downcast( node_base );
199
200 _Scheduler_priority_Ready_queue_enqueue(
201 &node->Base.Base.Node.Chain,
202 &node->Ready_queue,
203 &self->Bit_map
204 );
205}
206
207static inline void _Scheduler_priority_SMP_Do_update(
209 Scheduler_Node *node_to_update,
210 Priority_Control new_priority
211)
212{
215
216 self = _Scheduler_priority_SMP_Get_self( context );
217 node = _Scheduler_priority_SMP_Node_downcast( node_to_update );
218
219 _Scheduler_SMP_Node_update_priority( &node->Base, new_priority );
220 _Scheduler_priority_Ready_queue_update(
221 &node->Ready_queue,
222 SCHEDULER_PRIORITY_UNMAP( new_priority ),
223 &self->Bit_map,
224 &self->Ready[ 0 ]
225 );
226}
227
230#ifdef __cplusplus
231}
232#endif /* __cplusplus */
233
234#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H */
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:91
#define SCHEDULER_PRIORITY_APPEND(priority)
Returns the priority control with the append indicator bit set.
Definition: schedulernodeimpl.h:81
#define SCHEDULER_PRIORITY_UNMAP(priority)
Returns the plain priority value.
Definition: schedulernodeimpl.h:70
#define SCHEDULER_PRIORITY_IS_APPEND(priority)
Returns true, if the item should be appended to its priority group, otherwise returns false and the i...
Definition: schedulernodeimpl.h:89
rtems_termios_device_context * context
Definition: console-config.c:62
This header file provides interfaces of the Deterministic Priority Scheduler which are only used by t...
This header file provides interfaces of the Deterministic Priority SMP Scheduler which are used by th...
This header file provides interfaces of the Simple Priority Scheduler which are only used by the impl...
This header file provides interfaces of the SMP Scheduler which are only used by the implementation.
Scheduler context.
Definition: scheduler.h:318
Scheduler node for per-thread data.
Definition: schedulernode.h:94
Chain_Control Scheduled
The chain of scheduled nodes.
Definition: schedulersmp.h:70
Scheduler_Node Base
Basic scheduler node.
Definition: schedulersmp.h:110
Scheduler context specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:71
Scheduler node specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:82
Scheduler_priority_Ready_queue Ready_queue
The associated ready queue of this node.
Definition: schedulerprioritysmp.h:91
Scheduler_SMP_Node Base
SMP scheduler node.
Definition: schedulerprioritysmp.h:86
Definition: thread.h:812