1 | /** |
---|
2 | * @file rtems/score/scheduleredf.h |
---|
3 | * |
---|
4 | * @brief Data Related to the Manipulation of Threads for the EDF Scheduler |
---|
5 | * |
---|
6 | * This include file contains all the constants and structures associated |
---|
7 | * with the manipulation of threads for the EDF scheduler. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * Copryight (c) 2011 Petr Benes. |
---|
12 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_SCHEDULEREDF_H |
---|
20 | #define _RTEMS_SCORE_SCHEDULEREDF_H |
---|
21 | |
---|
22 | #include <rtems/score/priority.h> |
---|
23 | #include <rtems/score/scheduler.h> |
---|
24 | #include <rtems/score/schedulerpriority.h> |
---|
25 | #include <rtems/score/rbtree.h> |
---|
26 | |
---|
27 | #include <limits.h> |
---|
28 | |
---|
29 | #ifdef __cplusplus |
---|
30 | extern "C" { |
---|
31 | #endif |
---|
32 | |
---|
33 | /** |
---|
34 | * @defgroup ScoreSchedulerEDF EDF Scheduler |
---|
35 | * |
---|
36 | * @ingroup ScoreScheduler |
---|
37 | */ |
---|
38 | /**@{*/ |
---|
39 | |
---|
40 | /* |
---|
41 | * Actually the EDF scheduler supports a maximum priority of |
---|
42 | * 0x7fffffffffffffff, but the user API is limited to uint32_t or int for |
---|
43 | * thread priorities. Ignore ILP64 targets for now. |
---|
44 | */ |
---|
45 | #define SCHEDULER_EDF_MAXIMUM_PRIORITY INT_MAX |
---|
46 | |
---|
47 | /** |
---|
48 | * Entry points for the Earliest Deadline First Scheduler. |
---|
49 | */ |
---|
50 | #define SCHEDULER_EDF_ENTRY_POINTS \ |
---|
51 | { \ |
---|
52 | _Scheduler_EDF_Initialize, /* initialize entry point */ \ |
---|
53 | _Scheduler_EDF_Schedule, /* schedule entry point */ \ |
---|
54 | _Scheduler_EDF_Yield, /* yield entry point */ \ |
---|
55 | _Scheduler_EDF_Block, /* block entry point */ \ |
---|
56 | _Scheduler_EDF_Unblock, /* unblock entry point */ \ |
---|
57 | _Scheduler_EDF_Update_priority, /* update priority entry point */ \ |
---|
58 | _Scheduler_EDF_Map_priority, /* map priority entry point */ \ |
---|
59 | _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \ |
---|
60 | SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ |
---|
61 | _Scheduler_EDF_Node_initialize, /* node initialize entry point */ \ |
---|
62 | _Scheduler_default_Node_destroy, /* node destroy entry point */ \ |
---|
63 | _Scheduler_EDF_Release_job, /* new period of task */ \ |
---|
64 | _Scheduler_EDF_Cancel_job, /* cancel period of task */ \ |
---|
65 | _Scheduler_default_Tick, /* tick entry point */ \ |
---|
66 | _Scheduler_default_Start_idle /* start idle entry point */ \ |
---|
67 | SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ |
---|
68 | } |
---|
69 | |
---|
70 | typedef struct { |
---|
71 | /** |
---|
72 | * @brief Basic scheduler context. |
---|
73 | */ |
---|
74 | Scheduler_Context Base; |
---|
75 | |
---|
76 | /** |
---|
77 | * Top of the ready queue. |
---|
78 | */ |
---|
79 | RBTree_Control Ready; |
---|
80 | } Scheduler_EDF_Context; |
---|
81 | |
---|
82 | /** |
---|
83 | * @brief Scheduler node specialization for EDF schedulers. |
---|
84 | */ |
---|
85 | typedef struct { |
---|
86 | /** |
---|
87 | * @brief Basic scheduler node. |
---|
88 | */ |
---|
89 | Scheduler_Node Base; |
---|
90 | |
---|
91 | /** |
---|
92 | * Rbtree node related to this thread. |
---|
93 | */ |
---|
94 | RBTree_Node Node; |
---|
95 | |
---|
96 | /** |
---|
97 | * @brief The thread priority currently used for this scheduler instance. |
---|
98 | */ |
---|
99 | Priority_Control priority; |
---|
100 | } Scheduler_EDF_Node; |
---|
101 | |
---|
102 | /** |
---|
103 | * @brief Initialize EDF scheduler. |
---|
104 | * |
---|
105 | * This routine initializes the EDF scheduler. |
---|
106 | * |
---|
107 | * @param[in] scheduler The scheduler instance. |
---|
108 | */ |
---|
109 | void _Scheduler_EDF_Initialize( const Scheduler_Control *scheduler ); |
---|
110 | |
---|
111 | void _Scheduler_EDF_Block( |
---|
112 | const Scheduler_Control *scheduler, |
---|
113 | Thread_Control *the_thread, |
---|
114 | Scheduler_Node *node |
---|
115 | ); |
---|
116 | |
---|
117 | /** |
---|
118 | * @brief Sets the heir thread to be the next ready thread |
---|
119 | * in the rbtree ready queue. |
---|
120 | * |
---|
121 | * This kernel routine sets the heir thread to be the next ready thread |
---|
122 | * in the rbtree ready queue. |
---|
123 | * |
---|
124 | * @param[in] scheduler The scheduler instance. |
---|
125 | * @param[in] the_thread being scheduled. |
---|
126 | */ |
---|
127 | void _Scheduler_EDF_Schedule( |
---|
128 | const Scheduler_Control *scheduler, |
---|
129 | Thread_Control *the_thread |
---|
130 | ); |
---|
131 | |
---|
132 | /** |
---|
133 | * @brief Initializes an EDF specific scheduler node of @a the_thread. |
---|
134 | * |
---|
135 | * @param[in] scheduler The scheduler instance. |
---|
136 | * @param[in] node being initialized. |
---|
137 | * @param[in] the_thread the thread of the node. |
---|
138 | * @param[in] priority The thread priority. |
---|
139 | */ |
---|
140 | void _Scheduler_EDF_Node_initialize( |
---|
141 | const Scheduler_Control *scheduler, |
---|
142 | Scheduler_Node *node, |
---|
143 | Thread_Control *the_thread, |
---|
144 | Priority_Control priority |
---|
145 | ); |
---|
146 | |
---|
147 | void _Scheduler_EDF_Unblock( |
---|
148 | const Scheduler_Control *scheduler, |
---|
149 | Thread_Control *the_thread, |
---|
150 | Scheduler_Node *node |
---|
151 | ); |
---|
152 | |
---|
153 | void _Scheduler_EDF_Update_priority( |
---|
154 | const Scheduler_Control *scheduler, |
---|
155 | Thread_Control *the_thread, |
---|
156 | Scheduler_Node *node |
---|
157 | ); |
---|
158 | |
---|
159 | Priority_Control _Scheduler_EDF_Map_priority( |
---|
160 | const Scheduler_Control *scheduler, |
---|
161 | Priority_Control priority |
---|
162 | ); |
---|
163 | |
---|
164 | Priority_Control _Scheduler_EDF_Unmap_priority( |
---|
165 | const Scheduler_Control *scheduler, |
---|
166 | Priority_Control priority |
---|
167 | ); |
---|
168 | |
---|
169 | void _Scheduler_EDF_Yield( |
---|
170 | const Scheduler_Control *scheduler, |
---|
171 | Thread_Control *the_thread, |
---|
172 | Scheduler_Node *node |
---|
173 | ); |
---|
174 | |
---|
175 | void _Scheduler_EDF_Release_job( |
---|
176 | const Scheduler_Control *scheduler, |
---|
177 | Thread_Control *the_thread, |
---|
178 | Priority_Node *priority_node, |
---|
179 | uint64_t deadline, |
---|
180 | Thread_queue_Context *queue_context |
---|
181 | ); |
---|
182 | |
---|
183 | void _Scheduler_EDF_Cancel_job( |
---|
184 | const Scheduler_Control *scheduler, |
---|
185 | Thread_Control *the_thread, |
---|
186 | Priority_Node *priority_node, |
---|
187 | Thread_queue_Context *queue_context |
---|
188 | ); |
---|
189 | |
---|
190 | #ifdef __cplusplus |
---|
191 | } |
---|
192 | #endif |
---|
193 | |
---|
194 | /**@}*/ |
---|
195 | |
---|
196 | #endif |
---|
197 | /* end of include file */ |
---|