RTEMS  5.0.0
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 
44  _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler )
45 {
46  return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler );
47 }
48 
49 RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node(
50  Thread_Control *the_thread
51 )
52 {
53  return (Scheduler_EDF_Node *) _Thread_Scheduler_get_home_node( the_thread );
54 }
55 
56 RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
57  Scheduler_Node *node
58 )
59 {
60  return (Scheduler_EDF_Node *) node;
61 }
62 
63 RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less(
64  const void *left,
65  const RBTree_Node *right
66 )
67 {
68  const Priority_Control *the_left;
69  const Scheduler_EDF_Node *the_right;
70  Priority_Control prio_left;
71  Priority_Control prio_right;
72 
73  the_left = left;
74  the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
75 
76  prio_left = *the_left;
77  prio_right = the_right->priority;
78 
79  return prio_left < prio_right;
80 }
81 
82 RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal(
83  const void *left,
84  const RBTree_Node *right
85 )
86 {
87  const Priority_Control *the_left;
88  const Scheduler_EDF_Node *the_right;
89  Priority_Control prio_left;
90  Priority_Control prio_right;
91 
92  the_left = left;
93  the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
94 
95  prio_left = *the_left;
96  prio_right = the_right->priority;
97 
98  return prio_left <= prio_right;
99 }
100 
101 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue(
103  Scheduler_EDF_Node *node,
104  Priority_Control insert_priority
105 )
106 {
108  &context->Ready,
109  &node->Node,
110  &insert_priority,
111  _Scheduler_EDF_Priority_less_equal
112  );
113 }
114 
115 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract(
116  Scheduler_EDF_Context *context,
117  Scheduler_EDF_Node *node
118 )
119 {
120  _RBTree_Extract( &context->Ready, &node->Node );
121 }
122 
123 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body(
124  const Scheduler_Control *scheduler,
125  Thread_Control *the_thread,
126  Scheduler_Node *node
127 )
128 {
130  Scheduler_EDF_Node *the_node;
131 
132  context = _Scheduler_EDF_Get_context( scheduler );
133  the_node = _Scheduler_EDF_Node_downcast( node );
134 
135  _Scheduler_EDF_Extract( context, the_node );
136 }
137 
138 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(
139  const Scheduler_Control *scheduler,
140  Thread_Control *the_thread,
141  bool force_dispatch
142 )
143 {
145  RBTree_Node *first;
146  Scheduler_EDF_Node *node;
147 
148  (void) the_thread;
149 
150  context = _Scheduler_EDF_Get_context( scheduler );
151  first = _RBTree_Minimum( &context->Ready );
152  node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
153 
154  _Scheduler_Update_heir( node->Base.owner, force_dispatch );
155 }
156 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif
164 /* end of include file */
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:483
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:85
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
Inlined Routines Associated with the Manipulation of the Scheduler.
Data Related to the Manipulation of Threads for the EDF Scheduler.
Red-black tree node.
Definition: rbtree.h:50
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
Definition: thread.h:728
struct _Thread_Control * owner
The thread owning this node.
Definition: schedulernode.h:109
Priority_Control priority
The thread priority currently used for this scheduler instance.
Definition: scheduleredf.h:99
RBTree_Node * _RBTree_Minimum(const RBTree_Control *the_rbtree)
Returns the minimum node of the red-black tree.
Definition: rbtreenext.c:36
RBTree_Node Node
Definition: scheduleredf.h:94
Scheduler_Node Base
Basic scheduler node.
Definition: scheduleredf.h:89
Definition: scheduleredf.h:70
unsigned context
Definition: tlb.h:108
Scheduler control.
Definition: scheduler.h:266
Scheduler node for per-thread data.
Definition: schedulernode.h:65
RBTree_Control Ready
Definition: scheduleredf.h:79
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:35
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)
Returns a pointer to the container of a specified member pointer.
Definition: basedefs.h:390