source: rtems/cpukit/include/rtems/score/scheduleredfimpl.h @ 6852f7e

5
Last change on this file since 6852f7e was 6852f7e, checked in by Andreas Dachsberger <andreas.dachsberger@…>, on 04/12/19 at 07:30:38

doxygen: score: adjust doc in scheduleredfimpl.h to doxygen guidelines

Update #3706.

  • Property mode set to 100644
File size: 6.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreSchedulerEDF
5 *
6 * @brief EDF Scheduler Implementation
7 */
8
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
28/**
29 * @addtogroup RTEMSScoreSchedulerEDF
30 *
31 * @{
32 */
33
34/**
35 * This is just a most significant bit of Priority_Control type. It
36 * distinguishes threads which are deadline driven (priority
37 * represented by a lower number than @a SCHEDULER_EDF_PRIO_MSB) from those
38 * ones who do not have any deadlines and thus are considered background
39 * tasks.
40 */
41#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000
42
43/**
44 * @brief Gets the context of the scheduler.
45 *
46 * @param scheduler The scheduler instance.
47 *
48 * @return The scheduler context of @a scheduler.
49 */
50RTEMS_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
56/**
57 * @brief Gets the scheduler EDF node of the thread.
58 *
59 * @param the_thread The thread to get the scheduler node of.
60 *
61 * @return The EDF scheduler node of @a the_thread.
62 */
63RTEMS_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
70/**
71 * @brief Returns the scheduler EDF node for the scheduler node.
72 *
73 * @param node The scheduler node of which the scheduler EDF node is returned.
74 *
75 * @return The corresponding scheduler EDF node.
76 */
77RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
78  Scheduler_Node *node
79)
80{
81  return (Scheduler_EDF_Node *) node;
82}
83
84/**
85 * @brief Checks if @a left is less than the priority of the node @a right.
86 *
87 * @param left The priority on the left hand side of the comparison.
88 * @param right The node of which the priority is compared to left.
89 *
90 * @retval true @a left is less than the priority of @a right.
91 * @retval false @a left is greater or equal than the priority of @a right.
92 */
93RTEMS_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 = 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
112/**
113 * @brief Checks if @a left is less or equal than the priority of the node @a right.
114 *
115 * @param left The priority on the left hand side of the comparison.
116 * @param right The node of which the priority is compared to left.
117 *
118 * @retval true @a left is less or equal than the priority of @a right.
119 * @retval false @a left is greater than the priority of @a right.
120 */
121RTEMS_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 = 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
140/**
141 * @brief Inserts the scheduler node with the given priority in the ready
142 *      queue of the context.
143 *
144 * @param[in, out] context The context to insert the node in.
145 * @param node The node to be inserted.
146 * @param insert_priority The priority with which the node will be inserted.
147 */
148RTEMS_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
162/**
163 * @brief Extracts the scheduler node from the ready queue of the context.
164 *
165 * @param[in, out] context The context to extract the node from.
166 * @param[in, out] node The node to extract.
167 */
168RTEMS_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
176/**
177 * @brief Extracts the node from the context of the given scheduler.
178 *
179 * @param scheduler The scheduler instance.
180 * @param the_thread The thread is not used in this method.
181 * @param[in, out] node The node to be extracted.
182 */
183RTEMS_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
198/**
199 * @brief Schedules the next ready thread as the heir.
200 *
201 * @param scheduler The scheduler instance to schedule the minimum of the context of.
202 * @param the_thread This parameter is not used.
203 * @param force_dispatch Indicates whether the current heir is blocked even if it is
204 *      not set as preemptible.
205 */
206RTEMS_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
225/** @} */
226
227#ifdef __cplusplus
228}
229#endif
230
231#endif
232/* end of include file */
Note: See TracBrowser for help on using the repository browser.