source: rtems/cpukit/score/include/rtems/score/scheduleredf.h @ 254dc82

5
Last change on this file since 254dc82 was 254dc82, checked in by Sebastian Huber <sebastian.huber@…>, on 06/24/16 at 09:22:03

score: Change Priority_Control to 64-bit

A 32-bit Priority_Control limits the uptime to 49 days with a 1ms clock
tick in case the EDF scheduler is used. Increase it to 64-bit to enable
proper operation of the EDF scheduler,

Close 2173.

  • Property mode set to 100644
File size: 6.7 KB
Line 
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
30extern "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_default_Tick,         /* tick entry point */ \
65    _Scheduler_default_Start_idle    /* start idle entry point */ \
66    SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
67  }
68
69typedef struct {
70  /**
71   * @brief Basic scheduler context.
72   */
73  Scheduler_Context Base;
74
75  /**
76   * Top of the ready queue.
77   */
78  RBTree_Control Ready;
79} Scheduler_EDF_Context;
80
81/**
82 * @brief Scheduler node specialization for EDF schedulers.
83 */
84typedef struct {
85  /**
86   * @brief Basic scheduler node.
87   */
88  Scheduler_Node Base;
89
90  /**
91   * Pointer to corresponding Thread Control Block.
92   */
93  Thread_Control *thread;
94  /**
95   * Rbtree node related to this thread.
96   */
97  RBTree_Node Node;
98
99  /**
100   * @brief The thread priority used by this scheduler instance in case no job
101   * is released.
102   */
103  Priority_Control background_priority;
104
105  /**
106   * @brief The thread priority currently used by this scheduler instance.
107   */
108  Priority_Control current_priority;
109} Scheduler_EDF_Node;
110
111/**
112 *  @brief Initialize EDF scheduler.
113 *
114 *  This routine initializes the EDF scheduler.
115 *
116 *  @param[in] scheduler The scheduler instance.
117 */
118void _Scheduler_EDF_Initialize( const Scheduler_Control *scheduler );
119
120/**
121 *  @brief Removes thread from ready queue.
122 *
123 *  This routine removes @a the_thread from the scheduling decision,
124 *  that is, removes it from the ready queue.  It performs
125 *  any necessary scheduling operations including the selection of
126 *  a new heir thread.
127 *
128 *  @param[in] scheduler The scheduler instance.
129 *  @param[in] the_thread is the thread to be blocked.
130 */
131void _Scheduler_EDF_Block(
132  const Scheduler_Control *scheduler,
133  Thread_Control          *the_thread
134);
135
136/**
137 *  @brief Sets the heir thread to be the next ready thread
138 *  in the rbtree ready queue.
139 *
140 *  This kernel routine sets the heir thread to be the next ready thread
141 *  in the rbtree ready queue.
142 *
143 *  @param[in] scheduler The scheduler instance.
144 *  @param[in] the_thread being scheduled.
145 */
146void _Scheduler_EDF_Schedule(
147  const Scheduler_Control *scheduler,
148  Thread_Control          *the_thread
149);
150
151/**
152 *  @brief Initializes an EDF specific scheduler node of @a the_thread.
153 *
154 *  @param[in] scheduler The scheduler instance.
155 *  @param[in] the_thread being initialized.
156 *  @param[in] priority The thread priority.
157 */
158void _Scheduler_EDF_Node_initialize(
159  const Scheduler_Control *scheduler,
160  Thread_Control          *the_thread,
161  Priority_Control         priority
162);
163
164/**
165 *  @brief Adds @a the_thread to the scheduling decision.
166 *
167 *  This routine adds @a the_thread to the scheduling decision, that is,
168 *  adds it to the ready queue and updates any appropriate scheduling
169 *  variables, for example the heir thread.
170 *
171 *  @param[in] scheduler The scheduler instance.
172 *  @param[in] the_thread will be unblocked.
173 */
174Scheduler_Void_or_thread _Scheduler_EDF_Unblock(
175  const Scheduler_Control *scheduler,
176  Thread_Control          *the_thread
177);
178
179Scheduler_Void_or_thread _Scheduler_EDF_Update_priority(
180  const Scheduler_Control *scheduler,
181  Thread_Control          *the_thread
182);
183
184Priority_Control _Scheduler_EDF_Map_priority(
185  const Scheduler_Control *scheduler,
186  Priority_Control         priority
187);
188
189Priority_Control _Scheduler_EDF_Unmap_priority(
190  const Scheduler_Control *scheduler,
191  Priority_Control         priority
192);
193
194/**
195 *  @brief invoked when a thread wishes to voluntarily
196 *  transfer control of the processor to another thread
197 *  with equal deadline.
198 *
199 *  This routine is invoked when a thread wishes to voluntarily
200 *  transfer control of the processor to another thread in the queue with
201 *  equal deadline. This does not have to happen very often.
202 *
203 *  This routine will remove the specified THREAD from the ready queue
204 *  and place it back. The rbtree ready queue is responsible for FIFO ordering
205 *  in such a case.
206 *
207 *  @param[in] scheduler The scheduler instance.
208 *  @param[in,out] the_thread The yielding thread.
209 */
210Scheduler_Void_or_thread _Scheduler_EDF_Yield(
211  const Scheduler_Control *scheduler,
212  Thread_Control          *the_thread
213);
214
215/**
216 *  @brief Called when a new job of task is released.
217 *
218 *  This routine is called when a new job of task is released.
219 *  It is called only from Rate Monotonic manager in the beginning
220 *  of new period.
221 *
222 *  @param[in] scheduler The scheduler instance.
223 *  @param[in] the_thread is the owner of the job.
224 *  @param[in] deadline of the new job from now. If equal to 0,
225 *             the job was cancelled or deleted, thus a running task
226 *             has to be suspended.
227 */
228void _Scheduler_EDF_Release_job (
229  const Scheduler_Control *scheduler,
230  Thread_Control          *the_thread,
231  uint64_t                 deadline
232);
233
234#ifdef __cplusplus
235}
236#endif
237
238/**@}*/
239
240#endif
241/* end of include file */
Note: See TracBrowser for help on using the repository browser.