source: rtems/cpukit/include/rtems/score/scheduleredfimpl.h @ 7fe6d60

Last change on this file since 7fe6d60 was 7fe6d60, checked in by Sebastian Huber <sebastian.huber@…>, on 07/15/22 at 07:16:04

score: Remove PRIORITY_PSEUDO_ISR thread priority

The uniprocessor schedulers had some special case logic for the
PRIORITY_PSEUDO_ISR priority. Tasks with a priority of PRIORITY_PSEUDO_ISR
were allowed to preempt a not preemptible task. If other higher priority task
are made ready while a PRIORITY_PSEUDO_ISR task preempts a not preemptible
task, then the other tasks run before the not preemptible task. This made the
RTEMS_NO_PREEMPT mode ineffective.

Remove the PRIORITY_PSEUDO_ISR special case logic. This simplifies the
uniprocessor schedulers. Move the uniprocessor-specific scheduler support to
the new header file <rtems/score/scheduleruniimpl.h>.

Close #2365.

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSScoreSchedulerEDF
7 *
8 * @brief This header file provides interfaces of the
9 *   @ref RTEMSScoreSchedulerEDF which are only used by the implementation.
10 */
11
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
41#include <rtems/score/scheduleredf.h>
42#include <rtems/score/scheduleruniimpl.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/**
49 * @addtogroup RTEMSScoreSchedulerEDF
50 *
51 * @{
52 */
53
54/**
55 * This is just a most significant bit of Priority_Control type. It
56 * distinguishes threads which are deadline driven (priority
57 * represented by a lower number than @a SCHEDULER_EDF_PRIO_MSB) from those
58 * ones who do not have any deadlines and thus are considered background
59 * tasks.
60 */
61#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000
62
63/**
64 * @brief Gets the context of the scheduler.
65 *
66 * @param scheduler The scheduler instance.
67 *
68 * @return The scheduler context of @a scheduler.
69 */
70RTEMS_INLINE_ROUTINE Scheduler_EDF_Context *
71  _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler )
72{
73  return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler );
74}
75
76/**
77 * @brief Gets the scheduler EDF node of the thread.
78 *
79 * @param the_thread The thread to get the scheduler node of.
80 *
81 * @return The EDF scheduler node of @a the_thread.
82 */
83RTEMS_INLINE_ROUTINE 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
90/**
91 * @brief Returns the scheduler EDF node for the scheduler node.
92 *
93 * @param node The scheduler node of which the scheduler EDF node is returned.
94 *
95 * @return The corresponding scheduler EDF node.
96 */
97RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
98  Scheduler_Node *node
99)
100{
101  return (Scheduler_EDF_Node *) node;
102}
103
104/**
105 * @brief Checks if @a left is less than the priority of the node @a right.
106 *
107 * @param left The priority on the left hand side of the comparison.
108 * @param right The node of which the priority is compared to left.
109 *
110 * @retval true @a left is less than the priority of @a right.
111 * @retval false @a left is greater or equal than the priority of @a right.
112 */
113RTEMS_INLINE_ROUTINE 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 = 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
132/**
133 * @brief Checks if @a left is less or equal than the priority of the node @a right.
134 *
135 * @param left The priority on the left hand side of the comparison.
136 * @param right The node of which the priority is compared to left.
137 *
138 * @retval true @a left is less or equal than the priority of @a right.
139 * @retval false @a left is greater than the priority of @a right.
140 */
141RTEMS_INLINE_ROUTINE 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 = 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
160/**
161 * @brief Inserts the scheduler node with the given priority in the ready
162 *      queue of the context.
163 *
164 * @param[in, out] context The context to insert the node in.
165 * @param node The node to be inserted.
166 * @param insert_priority The priority with which the node will be inserted.
167 */
168RTEMS_INLINE_ROUTINE 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
182/**
183 * @brief Extracts the scheduler node from the ready queue of the context.
184 *
185 * @param[in, out] context The context to extract the node from.
186 * @param[in, out] node The node to extract.
187 */
188RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract(
189  Scheduler_EDF_Context *context,
190  Scheduler_EDF_Node    *node
191)
192{
193  _RBTree_Extract( &context->Ready, &node->Node );
194}
195
196/**
197 * @brief Extracts the node from the context of the given scheduler.
198 *
199 * @param scheduler The scheduler instance.
200 * @param the_thread The thread is not used in this method.
201 * @param[in, out] node The node to be extracted.
202 */
203RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body(
204  const Scheduler_Control *scheduler,
205  Thread_Control          *the_thread,
206  Scheduler_Node          *node
207)
208{
209  Scheduler_EDF_Context *context;
210  Scheduler_EDF_Node    *the_node;
211
212  context = _Scheduler_EDF_Get_context( scheduler );
213  the_node = _Scheduler_EDF_Node_downcast( node );
214
215  _Scheduler_EDF_Extract( context, the_node );
216}
217
218/**
219 * @brief Gets the highest priority ready thread of the scheduler.
220 *
221 * @param scheduler is the scheduler.
222 */
223RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_EDF_Get_highest_ready(
224  const Scheduler_Control *scheduler
225)
226{
227  Scheduler_EDF_Context *context;
228  RBTree_Node           *first;
229  Scheduler_EDF_Node    *node;
230
231  context = _Scheduler_EDF_Get_context( scheduler );
232  first = _RBTree_Minimum( &context->Ready );
233  node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
234
235  return node->Base.owner;
236}
237
238/** @} */
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif
245/* end of include file */
Note: See TracBrowser for help on using the repository browser.