RTEMS  5.0.0
schedulerprioritysmpimpl.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2013, 2017 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 #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H
24 #define _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H
25 
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
40 static inline Scheduler_priority_SMP_Context *_Scheduler_priority_SMP_Get_self(
42 )
43 {
45 }
46 
47 static inline Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Thread_get_node(
48  Thread_Control *thread
49 )
50 {
51  return (Scheduler_priority_SMP_Node *) _Thread_Scheduler_get_home_node( thread );
52 }
53 
54 static inline Scheduler_priority_SMP_Node *
55 _Scheduler_priority_SMP_Node_downcast( Scheduler_Node *node )
56 {
57  return (Scheduler_priority_SMP_Node *) node;
58 }
59 
60 static inline bool _Scheduler_priority_SMP_Has_ready( Scheduler_Context *context )
61 {
63  _Scheduler_priority_SMP_Get_self( context );
64 
65  return !_Priority_bit_map_Is_empty( &self->Bit_map );
66 }
67 
68 static inline void _Scheduler_priority_SMP_Move_from_scheduled_to_ready(
69  Scheduler_Context *context,
70  Scheduler_Node *scheduled_to_ready
71 )
72 {
74  _Scheduler_priority_SMP_Get_self( context );
76  _Scheduler_priority_SMP_Node_downcast( scheduled_to_ready );
77 
78  _Chain_Extract_unprotected( &node->Base.Base.Node.Chain );
80  &node->Base.Base.Node.Chain,
81  &node->Ready_queue,
82  &self->Bit_map
83  );
84 }
85 
86 static inline void _Scheduler_priority_SMP_Move_from_ready_to_scheduled(
87  Scheduler_Context *context,
88  Scheduler_Node *ready_to_scheduled
89 )
90 {
93  Priority_Control insert_priority;
94 
95  self = _Scheduler_priority_SMP_Get_self( context );
96  node = _Scheduler_priority_SMP_Node_downcast( ready_to_scheduled );
97 
99  &node->Base.Base.Node.Chain,
100  &node->Ready_queue,
101  &self->Bit_map
102  );
103  insert_priority = _Scheduler_SMP_Node_priority( &node->Base.Base );
104  insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority );
106  &self->Base.Scheduled,
107  &node->Base.Base.Node.Chain,
108  &insert_priority,
109  _Scheduler_SMP_Priority_less_equal
110  );
111 }
112 
113 static inline void _Scheduler_priority_SMP_Insert_ready(
114  Scheduler_Context *context,
115  Scheduler_Node *node_base,
116  Priority_Control insert_priority
117 )
118 {
121 
122  self = _Scheduler_priority_SMP_Get_self( context );
123  node = _Scheduler_priority_SMP_Node_downcast( node_base );
124 
125  if ( SCHEDULER_PRIORITY_IS_APPEND( insert_priority ) ) {
127  &node->Base.Base.Node.Chain,
128  &node->Ready_queue,
129  &self->Bit_map
130  );
131  } else {
133  &node->Base.Base.Node.Chain,
134  &node->Ready_queue,
135  &self->Bit_map
136  );
137  }
138 }
139 
140 static inline void _Scheduler_priority_SMP_Extract_from_ready(
141  Scheduler_Context *context,
142  Scheduler_Node *thread
143 )
144 {
146  _Scheduler_priority_SMP_Get_self( context );
148  _Scheduler_priority_SMP_Node_downcast( thread );
149 
151  &node->Base.Base.Node.Chain,
152  &node->Ready_queue,
153  &self->Bit_map
154  );
155 }
156 
157 static inline void _Scheduler_priority_SMP_Do_update(
158  Scheduler_Context *context,
159  Scheduler_Node *node_to_update,
160  Priority_Control new_priority
161 )
162 {
165 
166  self = _Scheduler_priority_SMP_Get_self( context );
167  node = _Scheduler_priority_SMP_Node_downcast( node_to_update );
168 
169  _Scheduler_SMP_Node_update_priority( &node->Base, new_priority );
171  &node->Ready_queue,
172  SCHEDULER_PRIORITY_UNMAP( new_priority ),
173  &self->Bit_map,
174  &self->Ready[ 0 ]
175  );
176 }
177 
180 #ifdef __cplusplus
181 }
182 #endif /* __cplusplus */
183 
184 #endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H */
RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected(Chain_Control *the_chain, Chain_Node *to_insert, const void *left, Chain_Node_order order)
Inserts a node into the chain according to the order relation.
Definition: chainimpl.h:860
#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: schedulerimpl.h:66
Inlined Routines Associated with the Manipulation of the Priority-Based Scheduling Structures...
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:105
Scheduler context.
Definition: scheduler.h:249
RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(Chain_Node *the_node)
Extract this node (unprotected).
Definition: chainimpl.h:557
Scheduler_SMP_Node Base
SMP scheduler node.
Definition: schedulerprioritysmp.h:68
Inlined Routines Associated with the Manipulation of the Priority-Based Scheduling Structures...
Deterministic Priority SMP Scheduler API.
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
Scheduler context specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:54
Definition: thread.h:728
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:124
Scheduler_priority_Ready_queue Ready_queue
The associated ready queue of this node.
Definition: schedulerprioritysmp.h:73
#define SCHEDULER_PRIORITY_UNMAP(priority)
Returns the plain priority value.
Definition: schedulerimpl.h:47
SMP Scheduler Implementation.
Scheduler_Node Base
Basic scheduler node.
Definition: schedulersmp.h:102
unsigned context
Definition: tlb.h:108
Scheduler node for per-thread data.
Definition: schedulernode.h:65
Scheduler node specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:64
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:217
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:84
#define SCHEDULER_PRIORITY_APPEND(priority)
Returns the priority control with the append indicator bit set.
Definition: schedulerimpl.h:58