source: rtems/cpukit/score/include/rtems/score/scheduleredfimpl.h @ 300f6a48

5
Last change on this file since 300f6a48 was 300f6a48, checked in by Sebastian Huber <sebastian.huber@…>, on 06/22/16 at 15:09:23

score: Rework thread priority management

Add priority nodes which contribute to the overall thread priority.

The actual priority of a thread is now an aggregation of priority nodes.
The thread priority aggregation for the home scheduler instance of a
thread consists of at least one priority node, which is normally the
real priority of the thread. The locking protocols (e.g. priority
ceiling and priority inheritance), rate-monotonic period objects and the
POSIX sporadic server add, change and remove priority nodes.

A thread changes its priority now immediately, e.g. priority changes are
not deferred until the thread releases its last resource.

Replace the _Thread_Change_priority() function with

  • _Thread_Priority_perform_actions(),
  • _Thread_Priority_add(),
  • _Thread_Priority_remove(),
  • _Thread_Priority_change(), and
  • _Thread_Priority_update().

Update #2412.
Update #2556.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSchedulerEDF
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 ScoreSchedulerEDF
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
43RTEMS_INLINE_ROUTINE Scheduler_EDF_Context *
44  _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler )
45{
46  return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler );
47}
48
49RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node(
50  Thread_Control *the_thread
51)
52{
53  return (Scheduler_EDF_Node *) _Scheduler_Thread_get_node( the_thread );
54}
55
56RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast(
57  Scheduler_Node *node
58)
59{
60  return (Scheduler_EDF_Node *) node;
61}
62
63RTEMS_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
82RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less_or_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
101RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue(
102  Scheduler_EDF_Context *context,
103  Scheduler_EDF_Node    *node,
104  Priority_Control       priority
105)
106{
107  _RBTree_Insert_inline(
108    &context->Ready,
109    &node->Node,
110    &priority,
111    _Scheduler_EDF_Less
112  );
113}
114
115RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue_first(
116  Scheduler_EDF_Context *context,
117  Scheduler_EDF_Node    *node,
118  Priority_Control       priority
119)
120{
121  _RBTree_Insert_inline(
122    &context->Ready,
123    &node->Node,
124    &priority,
125    _Scheduler_EDF_Less_or_equal
126  );
127}
128
129RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract(
130  Scheduler_EDF_Context *context,
131  Scheduler_EDF_Node    *node
132)
133{
134  _RBTree_Extract( &context->Ready, &node->Node );
135}
136
137RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body(
138  const Scheduler_Control *scheduler,
139  Thread_Control          *the_thread
140)
141{
142  Scheduler_EDF_Context *context;
143  Scheduler_EDF_Node    *node;
144
145  context = _Scheduler_EDF_Get_context( scheduler );
146  node = _Scheduler_EDF_Thread_get_node( the_thread );
147
148  _Scheduler_EDF_Extract( context, node );
149}
150
151RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(
152  const Scheduler_Control *scheduler,
153  Thread_Control          *the_thread,
154  bool                     force_dispatch
155)
156{
157  Scheduler_EDF_Context *context;
158  RBTree_Node           *first;
159  Scheduler_EDF_Node    *node;
160
161  (void) the_thread;
162
163  context = _Scheduler_EDF_Get_context( scheduler );
164  first = _RBTree_Minimum( &context->Ready );
165  node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
166
167  _Scheduler_Update_heir( node->Base.owner, force_dispatch );
168}
169
170/**@}*/
171
172#ifdef __cplusplus
173}
174#endif
175
176#endif
177/* end of include file */
Note: See TracBrowser for help on using the repository browser.