RTEMS  5.1
scheduleredfimpl.h
Go to the documentation of this file.
1 
9 /*
10  * Copryight (c) 2011 Petr Benes.
11  * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifndef _RTEMS_SCORE_SCHEDULEREDFIMPL_H
19 #define _RTEMS_SCORE_SCHEDULEREDFIMPL_H
20 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
41 #define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000
42 
52 {
53  return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler );
54 }
55 
64  Thread_Control *the_thread
65 )
66 {
67  return (Scheduler_EDF_Node *) _Thread_Scheduler_get_home_node( the_thread );
68 }
69 
78  Scheduler_Node *node
79 )
80 {
81  return (Scheduler_EDF_Node *) node;
82 }
83 
94  const void *left,
95  const RBTree_Node *right
96 )
97 {
98  const Priority_Control *the_left;
99  const Scheduler_EDF_Node *the_right;
100  Priority_Control prio_left;
101  Priority_Control prio_right;
102 
103  the_left = left;
104  the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
105 
106  prio_left = *the_left;
107  prio_right = the_right->priority;
108 
109  return prio_left < prio_right;
110 }
111 
122  const void *left,
123  const RBTree_Node *right
124 )
125 {
126  const Priority_Control *the_left;
127  const Scheduler_EDF_Node *the_right;
128  Priority_Control prio_left;
129  Priority_Control prio_right;
130 
131  the_left = left;
132  the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
133 
134  prio_left = *the_left;
135  prio_right = the_right->priority;
136 
137  return prio_left <= prio_right;
138 }
139 
150  Scheduler_EDF_Node *node,
151  Priority_Control insert_priority
152 )
153 {
155  &context->Ready,
156  &node->Node,
157  &insert_priority,
159  );
160 }
161 
170  Scheduler_EDF_Node *node
171 )
172 {
173  _RBTree_Extract( &context->Ready, &node->Node );
174 }
175 
184  const Scheduler_Control *scheduler,
185  Thread_Control *the_thread,
186  Scheduler_Node *node
187 )
188 {
190  Scheduler_EDF_Node *the_node;
191 
192  context = _Scheduler_EDF_Get_context( scheduler );
193  the_node = _Scheduler_EDF_Node_downcast( node );
194 
195  _Scheduler_EDF_Extract( context, the_node );
196 }
197 
207  const Scheduler_Control *scheduler,
208  Thread_Control *the_thread,
209  bool force_dispatch
210 )
211 {
213  RBTree_Node *first;
214  Scheduler_EDF_Node *node;
215 
216  (void) the_thread;
217 
218  context = _Scheduler_EDF_Get_context( scheduler );
219  first = _RBTree_Minimum( &context->Ready );
220  node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
221 
222  _Scheduler_Update_heir( node->Base.owner, force_dispatch );
223 }
224 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif
232 /* end of include file */
RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(Scheduler_Node *node)
Returns the scheduler EDF node for the scheduler node.
Definition: scheduleredfimpl.h:77
RTEMS_INLINE_ROUTINE Scheduler_Context * _Scheduler_Get_context(const Scheduler_Control *scheduler)
Gets the context of the scheduler.
Definition: schedulerimpl.h:58
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
RTEMS_INLINE_ROUTINE bool _RBTree_Insert_inline(RBTree_Control *the_rbtree, RBTree_Node *the_node, const void *key, bool(*less)(const void *, const RBTree_Node *))
Inserts the node into the red-black tree.
Definition: rbtree.h:508
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:90
Inlined Routines Associated with the Manipulation of the Scheduler.
Data Related to the Manipulation of Threads for the EDF Scheduler.
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)
Returns a pointer to the container of a specified member pointer.
Definition: basedefs.h:430
Red-black tree node.
Definition: rbtree.h:55
RBTree_Node * _RBTree_Minimum(const RBTree_Control *the_rbtree)
Returns the minimum node of the red-black tree.
Definition: rbtreenext.c:36
RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(Thread_Control *new_heir, bool force_dispatch)
Updates the heir.
Definition: schedulerimpl.h:1184
RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal(const void *left, const RBTree_Node *right)
Checks if left is less or equal than the priority of the node right.
Definition: scheduleredfimpl.h:121
Definition: thread.h:732
RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less(const void *left, const RBTree_Node *right)
Checks if left is less than the priority of the node right.
Definition: scheduleredfimpl.h:93
RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue(Scheduler_EDF_Context *context, Scheduler_EDF_Node *node, Priority_Control insert_priority)
Inserts the scheduler node with the given priority in the ready queue of the context.
Definition: scheduleredfimpl.h:148
RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract(Scheduler_EDF_Context *context, Scheduler_EDF_Node *node)
Extracts the scheduler node from the ready queue of the context.
Definition: scheduleredfimpl.h:168
RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * _Scheduler_EDF_Get_context(const Scheduler_Control *scheduler)
Gets the context of the scheduler.
Definition: scheduleredfimpl.h:51
struct _Thread_Control * owner
The thread owning this node.
Definition: schedulernode.h:123
Priority_Control priority
The thread priority currently used for this scheduler instance.
Definition: scheduleredf.h:104
RBTree_Node Node
Definition: scheduleredf.h:99
Scheduler_Node Base
Basic scheduler node.
Definition: scheduleredf.h:94
RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(const Scheduler_Control *scheduler, Thread_Control *the_thread, bool force_dispatch)
Schedules the next ready thread as the heir.
Definition: scheduleredfimpl.h:206
Definition: scheduleredf.h:75
unsigned context
Definition: tlb.h:108
Scheduler control.
Definition: scheduler.h:269
Scheduler node for per-thread data.
Definition: schedulernode.h:79
RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Thread_get_node(Thread_Control *the_thread)
Gets the scheduler EDF node of the thread.
Definition: scheduleredfimpl.h:63
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:35
RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Extracts the node from the context of the given scheduler.
Definition: scheduleredfimpl.h:183
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
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