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

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
21#include <rtems/score/scheduleredf.h>
22#include <rtems/score/schedulerimpl.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
41#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000
42
50 RTEMS_INLINE_ROUTINE Scheduler_EDF_Context *
51 _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler )
52{
53 return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler );
54}
55
63 RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node(
64 Thread_Control *the_thread
65)
66{
67 return (Scheduler_EDF_Node *) _Thread_Scheduler_get_home_node( the_thread );
68}
69
77 RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
78 Scheduler_Node *node
79)
80{
81 return (Scheduler_EDF_Node *) node;
82}
83
93 RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less(
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 = (const Priority_Control*) 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
121 RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal(
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 = (const Priority_Control*) 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
148 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue(
149 Scheduler_EDF_Context *context,
150 Scheduler_EDF_Node *node,
151 Priority_Control insert_priority
152)
153{
154 _RBTree_Insert_inline(
155 &context->Ready,
156 &node->Node,
157 &insert_priority,
158 _Scheduler_EDF_Priority_less_equal
159 );
160}
161
168 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract(
169 Scheduler_EDF_Context *context,
170 Scheduler_EDF_Node *node
171)
172{
173 _RBTree_Extract( &context->Ready, &node->Node );
174}
175
183 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body(
184 const Scheduler_Control *scheduler,
185 Thread_Control *the_thread,
186 Scheduler_Node *node
187)
188{
189 Scheduler_EDF_Context *context;
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
206 RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(
207 const Scheduler_Control *scheduler,
208 Thread_Control *the_thread,
209 bool force_dispatch
210)
211{
212 Scheduler_EDF_Context *context;
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_CONTAINER_OF
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)
Returns a pointer to the container of a specified member pointer.
Definition: basedefs.h:430
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
Priority_Control
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
_RBTree_Extract
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:35
_RBTree_Insert_inline
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
_RBTree_Minimum
RBTree_Node * _RBTree_Minimum(const RBTree_Control *the_rbtree)
Returns the minimum node of the red-black tree.
Definition: rbtreenext.c:36
_Scheduler_EDF_Extract_body
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
_Scheduler_EDF_Extract
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
_Scheduler_EDF_Priority_less_equal
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
_Scheduler_EDF_Thread_get_node
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
_Scheduler_EDF_Node_downcast
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
_Scheduler_EDF_Less
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
_Scheduler_EDF_Schedule_body
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
_Scheduler_EDF_Get_context
RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * _Scheduler_EDF_Get_context(const Scheduler_Control *scheduler)
Gets the context of the scheduler.
Definition: scheduleredfimpl.h:51
_Scheduler_EDF_Enqueue
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
_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
scheduleredf.h
Data Related to the Manipulation of Threads for the EDF Scheduler.
schedulerimpl.h
Inlined Routines Associated with the Manipulation of the Scheduler.
RBTree_Node
Red-black tree node.
Definition: rbtree.h:55
Scheduler_EDF_Context
Definition: scheduleredf.h:75
Scheduler_EDF_Node
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:90
Scheduler_EDF_Node::priority
Priority_Control priority
The thread priority currently used for this scheduler instance.
Definition: scheduleredf.h:104
Scheduler_EDF_Node::Node
RBTree_Node Node
Definition: scheduleredf.h:99
Scheduler_EDF_Node::Base
Scheduler_Node Base
Basic scheduler node.
Definition: scheduleredf.h:94
Scheduler_Node
Scheduler node for per-thread data.
Definition: schedulernode.h:79
Scheduler_Node::owner
struct _Thread_Control * owner
The thread owning this node.
Definition: schedulernode.h:123
_Scheduler_Control
Scheduler control.
Definition: scheduler.h:269
_Thread_Control
Definition: thread.h:732