RTEMS 7.0-rc1
Loading...
Searching...
No Matches
scheduleredfimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copryight (c) 2011 Petr Benes.
14 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_SCORE_SCHEDULEREDFIMPL_H
39#define _RTEMS_SCORE_SCHEDULEREDFIMPL_H
40
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
61#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000
62
70static inline Scheduler_EDF_Context *
71 _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler )
72{
73 return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler );
74}
75
83static inline Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node(
84 Thread_Control *the_thread
85)
86{
87 return (Scheduler_EDF_Node *) _Thread_Scheduler_get_home_node( the_thread );
88}
89
97static inline Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
98 Scheduler_Node *node
99)
100{
101 return (Scheduler_EDF_Node *) node;
102}
103
113static inline bool _Scheduler_EDF_Less(
114 const void *left,
115 const RBTree_Node *right
116)
117{
118 const Priority_Control *the_left;
119 const Scheduler_EDF_Node *the_right;
120 Priority_Control prio_left;
121 Priority_Control prio_right;
122
123 the_left = (const Priority_Control *) left;
124 the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
125
126 prio_left = *the_left;
127 prio_right = the_right->priority;
128
129 return prio_left < prio_right;
130}
131
141static inline bool _Scheduler_EDF_Priority_less_equal(
142 const void *left,
143 const RBTree_Node *right
144)
145{
146 const Priority_Control *the_left;
147 const Scheduler_EDF_Node *the_right;
148 Priority_Control prio_left;
149 Priority_Control prio_right;
150
151 the_left = (const Priority_Control *) left;
152 the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
153
154 prio_left = *the_left;
155 prio_right = the_right->priority;
156
157 return prio_left <= prio_right;
158}
159
168static inline void _Scheduler_EDF_Enqueue(
169 Scheduler_EDF_Context *context,
170 Scheduler_EDF_Node *node,
171 Priority_Control insert_priority
172)
173{
174 _RBTree_Insert_inline(
175 &context->Ready,
176 &node->Node,
177 &insert_priority,
178 _Scheduler_EDF_Priority_less_equal
179 );
180}
181
188static inline void _Scheduler_EDF_Extract(
189 Scheduler_EDF_Context *context,
191)
192{
193 _RBTree_Extract( &context->Ready, &node->Node );
194}
195
203static inline void _Scheduler_EDF_Extract_body(
204 const Scheduler_Control *scheduler,
205 Thread_Control *the_thread,
206 Scheduler_Node *node
207)
208{
209 (void) the_thread;
210
211 Scheduler_EDF_Context *context;
212 Scheduler_EDF_Node *the_node;
213
214 context = _Scheduler_EDF_Get_context( scheduler );
215 the_node = _Scheduler_EDF_Node_downcast( node );
216
217 _Scheduler_EDF_Extract( context, the_node );
218}
219
225static inline Thread_Control *_Scheduler_EDF_Get_highest_ready(
226 const Scheduler_Control *scheduler
227)
228{
229 Scheduler_EDF_Context *context;
230 RBTree_Node *first;
231 Scheduler_EDF_Node *node;
232
233 context = _Scheduler_EDF_Get_context( scheduler );
234 first = _RBTree_Minimum( &context->Ready );
235 node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
236
237 return node->Base.owner;
238}
239
242#ifdef __cplusplus
243}
244#endif
245
246#endif
247/* end of include file */
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)
Gets the container of a member.
Definition: basedefs.h:306
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:91
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:63
RBTree_Node * _RBTree_Minimum(const RBTree_Control *the_rbtree)
Returns the minimum node of the red-black tree.
Definition: rbtreemin.c:43
This header file provides interfaces of the EDF Scheduler which are used by the implementation and th...
This header file provides interfaces of the supporting the implementation of uniprocessor schedulers.
Red-black tree node.
Definition: rbtree.h:73
Definition: scheduleredf.h:85
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:100
Priority_Control priority
The thread priority currently used for this scheduler instance.
Definition: scheduleredf.h:114
Scheduler node for per-thread data.
Definition: schedulernode.h:94
Scheduler control.
Definition: scheduler.h:337
Definition: thread.h:837