source: rtems/cpukit/score/include/rtems/score/scheduleredfimpl.h @ b5f1b24

5
Last change on this file since b5f1b24 was e382a1b, checked in by Sebastian Huber <sebastian.huber@…>, on 10/10/16 at 12:33:17

score: Pass scheduler node to block operation

Changed for consistency with other scheduler operations.

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  Scheduler_Node          *node
141)
142{
143  Scheduler_EDF_Context *context;
144  Scheduler_EDF_Node    *the_node;
145
146  context = _Scheduler_EDF_Get_context( scheduler );
147  the_node = _Scheduler_EDF_Node_downcast( node );
148
149  _Scheduler_EDF_Extract( context, the_node );
150}
151
152RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body(
153  const Scheduler_Control *scheduler,
154  Thread_Control          *the_thread,
155  bool                     force_dispatch
156)
157{
158  Scheduler_EDF_Context *context;
159  RBTree_Node           *first;
160  Scheduler_EDF_Node    *node;
161
162  (void) the_thread;
163
164  context = _Scheduler_EDF_Get_context( scheduler );
165  first = _RBTree_Minimum( &context->Ready );
166  node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node );
167
168  _Scheduler_Update_heir( node->Base.owner, force_dispatch );
169}
170
171/**@}*/
172
173#ifdef __cplusplus
174}
175#endif
176
177#endif
178/* end of include file */
Note: See TracBrowser for help on using the repository browser.