RTEMS: cpukit/include/rtems/score/schedulerpriorityimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
schedulerpriorityimpl.h
Go to the documentation of this file.
1
13/*
14 * Copyright (C) 2010 Gedare Bloom.
15 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.org/license/LICENSE.
20 */
21
22#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H
23#define _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H
24
25#include <rtems/score/schedulerpriority.h>
26#include <rtems/score/chainimpl.h>
27#include <rtems/score/prioritybitmapimpl.h>
28#include <rtems/score/schedulerimpl.h>
29#include <rtems/score/thread.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
48 RTEMS_INLINE_ROUTINE Scheduler_priority_Context *
49 _Scheduler_priority_Get_context( const Scheduler_Control *scheduler )
50{
51 return (Scheduler_priority_Context *) _Scheduler_Get_context( scheduler );
52}
53
61 RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_node(
62 Thread_Control *the_thread
63)
64{
65 return (Scheduler_priority_Node *) _Thread_Scheduler_get_home_node( the_thread );
66}
67
75 RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast(
76 Scheduler_Node *node
77)
78{
79 return (Scheduler_priority_Node *) node;
80}
81
90 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(
91 Chain_Control *ready_queues,
92 Priority_Control maximum_priority
93)
94{
95 size_t index;
96
97 for ( index = 0 ; index <= (size_t) maximum_priority ; ++index ) {
98 _Chain_Initialize_empty( &ready_queues[ index ] );
99 }
100}
101
111 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
112 Chain_Node *node,
113 Scheduler_priority_Ready_queue *ready_queue,
114 Priority_bit_map_Control *bit_map
115)
116{
117 Chain_Control *ready_chain = ready_queue->ready_chain;
118
119 _Chain_Append_unprotected( ready_chain, node );
120 _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
121}
122
132 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
133 Chain_Node *node,
134 Scheduler_priority_Ready_queue *ready_queue,
135 Priority_bit_map_Control *bit_map
136)
137{
138 Chain_Control *ready_chain = ready_queue->ready_chain;
139
140 _Chain_Prepend_unprotected( ready_chain, node );
141 _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
142}
143
151 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
152 Chain_Node *node,
153 Scheduler_priority_Ready_queue *ready_queue,
154 Priority_bit_map_Control *bit_map
155)
156{
157 Chain_Control *ready_chain = ready_queue->ready_chain;
158
159 if ( _Chain_Has_only_one_node( ready_chain ) ) {
160 _Chain_Initialize_empty( ready_chain );
161 _Chain_Initialize_node( node );
162 _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
163 } else {
164 _Chain_Extract_unprotected( node );
165 }
166}
167
175 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(
176 const Scheduler_Control *scheduler,
177 Thread_Control *the_thread,
178 Scheduler_Node *node
179)
180{
181 Scheduler_priority_Context *context;
182 Scheduler_priority_Node *the_node;
183
184 context = _Scheduler_priority_Get_context( scheduler );
185 the_node = _Scheduler_priority_Node_downcast( node );
186
187 _Scheduler_priority_Ready_queue_extract(
188 &the_thread->Object.Node,
189 &the_node->Ready_queue,
190 &context->Bit_map
191 );
192}
193
204 RTEMS_INLINE_ROUTINE Chain_Node *_Scheduler_priority_Ready_queue_first(
205 Priority_bit_map_Control *bit_map,
206 Chain_Control *ready_queues
207)
208{
209 Priority_Control index = _Priority_bit_map_Get_highest( bit_map );
210 Chain_Node *first = _Chain_First( &ready_queues[ index ] );
211
212 _Assert( first != _Chain_Tail( &ready_queues[ index ] ) );
213
214 return first;
215}
216
228 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(
229 const Scheduler_Control *scheduler,
230 Thread_Control *the_thread,
231 bool force_dispatch
232)
233{
234 Scheduler_priority_Context *context =
235 _Scheduler_priority_Get_context( scheduler );
236 Thread_Control *heir = (Thread_Control *)
237 _Scheduler_priority_Ready_queue_first(
238 &context->Bit_map,
239 &context->Ready[ 0 ]
240 );
241
242 ( void ) the_thread;
243
244 _Scheduler_Update_heir( heir, force_dispatch );
245}
246
256 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update(
257 Scheduler_priority_Ready_queue *ready_queue,
258 unsigned int new_priority,
259 Priority_bit_map_Control *bit_map,
260 Chain_Control *ready_queues
261)
262{
263 ready_queue->current_priority = new_priority;
264 ready_queue->ready_chain = &ready_queues[ new_priority ];
265
266 _Priority_bit_map_Initialize_information(
267 bit_map,
268 &ready_queue->Priority_map,
269 new_priority
270 );
271}
272
275#ifdef __cplusplus
276}
277#endif
278
279#endif
280/* end of include file */
chainimpl.h
Chain Handler API.
_Assert
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Chain_Has_only_one_node
RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node(const Chain_Control *the_chain)
Checks if this chain has only one node.
Definition: chainimpl.h:450
_Chain_Initialize_empty
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
Definition: chainimpl.h:505
_Chain_Extract_unprotected
RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(Chain_Node *the_node)
Extracts this node (unprotected).
Definition: chainimpl.h:558
_Chain_Tail
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Returns pointer to chain tail.
Definition: chainimpl.h:227
_Chain_Prepend_unprotected
RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepends a node (unprotected).
Definition: chainimpl.h:732
_Chain_Append_unprotected
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
_Chain_Initialize_node
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
_Chain_First
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_First(const Chain_Control *the_chain)
Returns pointer to chain's first node.
Definition: chainimpl.h:260
_Priority_bit_map_Get_highest
RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest(const Priority_bit_map_Control *bit_map)
Gets highest portion of Priority queue bit map.
Definition: prioritybitmapimpl.h:196
Priority_Control
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
_Priority_bit_map_Add
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info)
Adds Priority queue bit map information.
Definition: prioritybitmapimpl.h:162
_Priority_bit_map_Initialize_information
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info, unsigned int new_priority)
Initializes the bit map information.
Definition: prioritybitmapimpl.h:234
_Priority_bit_map_Remove
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info)
Removes Priority queue bit map information.
Definition: prioritybitmapimpl.h:179
_Scheduler_priority_Ready_queue_enqueue_first
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Enqueues a node on the specified ready queue as first.
Definition: schedulerpriorityimpl.h:132
_Scheduler_priority_Thread_get_node
RTEMS_INLINE_ROUTINE Scheduler_priority_Node * _Scheduler_priority_Thread_get_node(Thread_Control *the_thread)
Gets the scheduler node of the thread.
Definition: schedulerpriorityimpl.h:61
_Scheduler_priority_Node_downcast
RTEMS_INLINE_ROUTINE Scheduler_priority_Node * _Scheduler_priority_Node_downcast(Scheduler_Node *node)
Gets the priority node of the scheduler node.
Definition: schedulerpriorityimpl.h:75
_Scheduler_priority_Ready_queue_extract
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Extracts a node from the specified ready queue.
Definition: schedulerpriorityimpl.h:151
_Scheduler_priority_Ready_queue_update
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update(Scheduler_priority_Ready_queue *ready_queue, unsigned int new_priority, Priority_bit_map_Control *bit_map, Chain_Control *ready_queues)
Updates the specified ready queue data according to the new priority value.
Definition: schedulerpriorityimpl.h:256
_Scheduler_priority_Ready_queue_enqueue
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Enqueues a node on the specified ready queue.
Definition: schedulerpriorityimpl.h:111
_Scheduler_priority_Ready_queue_initialize
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(Chain_Control *ready_queues, Priority_Control maximum_priority)
Ready queue initialization.
Definition: schedulerpriorityimpl.h:90
_Scheduler_priority_Schedule_body
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(const Scheduler_Control *scheduler, Thread_Control *the_thread, bool force_dispatch)
Scheduling decision logic.
Definition: schedulerpriorityimpl.h:228
_Scheduler_priority_Ready_queue_first
RTEMS_INLINE_ROUTINE Chain_Node * _Scheduler_priority_Ready_queue_first(Priority_bit_map_Control *bit_map, Chain_Control *ready_queues)
Returns a pointer to the first node.
Definition: schedulerpriorityimpl.h:204
_Scheduler_priority_Get_context
RTEMS_INLINE_ROUTINE Scheduler_priority_Context * _Scheduler_priority_Get_context(const Scheduler_Control *scheduler)
Gets the context of the scheduler.
Definition: schedulerpriorityimpl.h:49
_Scheduler_priority_Extract_body
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Extracts a node from the context of the scheduler.
Definition: schedulerpriorityimpl.h:175
_Scheduler_Update_heir
RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(Thread_Control *new_heir, bool force_dispatch)
Updates the heir.
Definition: schedulerimpl.h:1184
_Scheduler_Get_context
RTEMS_INLINE_ROUTINE Scheduler_Context * _Scheduler_Get_context(const Scheduler_Control *scheduler)
Gets the context of the scheduler.
Definition: schedulerimpl.h:58
_Thread_Scheduler_get_home_node
RTEMS_INLINE_ROUTINE Scheduler_Node * _Thread_Scheduler_get_home_node(const Thread_Control *the_thread)
Gets the scheduler's home node.
Definition: threadimpl.h:1412
prioritybitmapimpl.h
Inlined Routines in the Priority Handler Bit Map Implementation.
schedulerimpl.h
Inlined Routines Associated with the Manipulation of the Scheduler.
schedulerpriority.h
Thread Manipulation with the Priority-Based Scheduler.
thread.h
Constants and Structures Related with the Thread Control Block.
Chain_Node_struct
Definition: chain.h:68
Objects_Control::Node
Chain_Node Node
Definition: objectdata.h:41
Priority_bit_map_Control
Definition: prioritybitmap.h:42
Scheduler_Node
Scheduler node for per-thread data.
Definition: schedulernode.h:79
Scheduler_priority_Context
Definition: schedulerpriority.h:65
Scheduler_priority_Node
Scheduler node specialization for Deterministic Priority schedulers.
Definition: schedulerpriority.h:101
Scheduler_priority_Node::Ready_queue
Scheduler_priority_Ready_queue Ready_queue
The associated ready queue of this node.
Definition: schedulerpriority.h:110
Scheduler_priority_Ready_queue
Data for ready queue operations.
Definition: schedulerpriority.h:85
Scheduler_priority_Ready_queue::current_priority
unsigned int current_priority
The thread priority currently used by the scheduler.
Definition: schedulerpriority.h:89
Scheduler_priority_Ready_queue::ready_chain
Chain_Control * ready_chain
Definition: schedulerpriority.h:92
Scheduler_priority_Ready_queue::Priority_map
Priority_bit_map_Information Priority_map
Definition: schedulerpriority.h:95
_Scheduler_Control
Scheduler control.
Definition: scheduler.h:269
_Thread_Control
Definition: thread.h:732
_Thread_Control::Object
Objects_Control Object
Definition: thread.h:734
Chain_Control
Definition: chain.h:86