source: rtems/cpukit/score/include/rtems/score/scheduleredf.h @ 8e467384

4.115
Last change on this file since 8e467384 was 8e467384, checked in by Sebastian Huber <sebastian.huber@…>, on 06/03/14 at 08:29:30

score: Replace _Scheduler_Allocate/Free()

Replace _Scheduler_Allocate() with _Scheduler_Node_initialize(). Remove
the return status and thus the node initialization must be always
successful.

Rename _Scheduler_Free() to _Scheduler_Node_destroy().

  • Property mode set to 100644
File size: 6.8 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#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 *  @defgroup ScoreSchedulerEDF EDF Scheduler
33 *
34 *  @ingroup ScoreScheduler
35 */
36/**@{*/
37
38/**
39 *  Entry points for the Earliest Deadline First Scheduler.
40 */
41#define SCHEDULER_EDF_ENTRY_POINTS \
42  { \
43    _Scheduler_EDF_Initialize,       /* initialize entry point */ \
44    _Scheduler_EDF_Schedule,         /* schedule entry point */ \
45    _Scheduler_EDF_Yield,            /* yield entry point */ \
46    _Scheduler_EDF_Block,            /* block entry point */ \
47    _Scheduler_EDF_Unblock,          /* unblock entry point */ \
48    _Scheduler_EDF_Change_priority,  /* change priority entry point */ \
49    _Scheduler_EDF_Node_initialize,  /* node initialize entry point */ \
50    _Scheduler_default_Node_destroy, /* node destroy entry point */ \
51    _Scheduler_EDF_Update,           /* update entry point */ \
52    _Scheduler_EDF_Priority_compare, /* compares two priorities */ \
53    _Scheduler_EDF_Release_job,      /* new period of task */ \
54    _Scheduler_default_Tick,         /* tick entry point */ \
55    _Scheduler_default_Start_idle    /* start idle entry point */ \
56  }
57
58/**
59 * This is just a most significant bit of Priority_Control type. It
60 * distinguishes threads which are deadline driven (priority
61 * represented by a lower number than @a SCHEDULER_EDF_PRIO_MSB) from those
62 * ones who do not have any deadlines and thus are considered background
63 * tasks.
64 */
65#define SCHEDULER_EDF_PRIO_MSB 0x80000000
66
67typedef struct {
68  /**
69   * @brief Basic scheduler context.
70   */
71  Scheduler_Context Base;
72
73  /**
74   * Top of the ready queue.
75   */
76  RBTree_Control Ready;
77} Scheduler_EDF_Context;
78
79/**
80 * @typedef Scheduler_EDF_Queue_state
81 *
82 * This enumeration distiguishes state of a thread with respect to the
83 * ready queue.
84 */
85typedef enum {
86  SCHEDULER_EDF_QUEUE_STATE_NOT_PRESENTLY,
87  SCHEDULER_EDF_QUEUE_STATE_YES,
88  SCHEDULER_EDF_QUEUE_STATE_NEVER_HAS_BEEN
89} Scheduler_EDF_Queue_state;
90
91/**
92 * @brief Scheduler node specialization for EDF schedulers.
93 */
94typedef struct {
95  /**
96   * @brief Basic scheduler node.
97   */
98  Scheduler_Node Base;
99
100  /**
101   * Pointer to corresponding Thread Control Block.
102   */
103  Thread_Control *thread;
104  /**
105   * Rbtree node related to this thread.
106   */
107  RBTree_Node Node;
108  /**
109   * State of the thread with respect to ready queue.
110   */
111  Scheduler_EDF_Queue_state queue_state;
112} Scheduler_EDF_Node;
113
114/**
115 * @brief Initialize EDF scheduler.
116 *
117 * This routine initializes the EDF scheduler.
118 */
119void _Scheduler_EDF_Initialize( const Scheduler_Control *scheduler );
120
121/**
122 *  @brief Removes thread from ready queue.
123 *
124 *  This routine removes @a the_thread from the scheduling decision,
125 *  that is, removes it from the ready queue.  It performs
126 *  any necessary scheduling operations including the selection of
127 *  a new heir thread.
128 *
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 */
143void _Scheduler_EDF_Schedule(
144  const Scheduler_Control *scheduler,
145  Thread_Control          *the_thread
146);
147
148/**
149 *  @brief Initializes an EDF specific scheduler node of @a the_thread.
150 */
151void _Scheduler_EDF_Node_initialize(
152  const Scheduler_Control *scheduler,
153  Thread_Control          *the_thread
154);
155
156/**
157 *  @brief Updates position in the ready queue of @a the_thread.
158 *
159 *  This routine updates position in the ready queue of @a the_thread.
160 *
161 *  @param[in] the_thread will have its scheduler specific information
162 *             structure updated.
163 */
164void _Scheduler_EDF_Update(
165  const Scheduler_Control *scheduler,
166  Thread_Control          *the_thread
167);
168
169/**
170 *  @brief Adds @a the_thread to the scheduling decision.
171 *
172 *  This routine adds @a the_thread to the scheduling decision, that is,
173 *  adds it to the ready queue and updates any appropriate scheduling
174 *  variables, for example the heir thread.
175 *
176 *  @param[in] the_thread will be unblocked.
177 */
178void _Scheduler_EDF_Unblock(
179  const Scheduler_Control *scheduler,
180  Thread_Control          *the_thread
181);
182
183void _Scheduler_EDF_Change_priority(
184  const Scheduler_Control *scheduler,
185  Thread_Control          *the_thread,
186  Priority_Control         new_priority,
187  bool                     prepend_it
188);
189
190/**
191 *  @brief invoked when a thread wishes to voluntarily
192 *  transfer control of the processor to another thread
193 *  with equal deadline.
194 *
195 *  This routine is invoked when a thread wishes to voluntarily
196 *  transfer control of the processor to another thread in the queue with
197 *  equal deadline. This does not have to happen very often.
198 *
199 *  This routine will remove the specified THREAD from the ready queue
200 *  and place it back. The rbtree ready queue is responsible for FIFO ordering
201 *  in such a case.
202 *
203 *  @param[in,out] thread The yielding thread.
204 */
205void _Scheduler_EDF_Yield(
206  const Scheduler_Control *scheduler,
207  Thread_Control          *the_thread
208);
209
210/**
211 *  @brief Explicitly compare absolute dedlines (priorities) of threads.
212 *
213 * This routine explicitly compares absolute dedlines (priorities) of threads.
214 * In case of EDF scheduling time overflow is taken into account.
215 *
216 * @retval >0 for p1 > p2; 0 for p1 == p2; <0 for p1 < p2.
217 */
218int _Scheduler_EDF_Priority_compare (
219  Priority_Control p1,
220  Priority_Control p2
221);
222
223/**
224 *  @brief Called when a new job of task is released.
225 *
226 *  This routine is called when a new job of task is released.
227 *  It is called only from Rate Monotonic manager in the beginning
228 *  of new period.
229 *
230 *  @param[in] the_thread is the owner of the job.
231 *  @param[in] deadline of the new job from now. If equal to 0,
232 *             the job was cancelled or deleted, thus a running task
233 *             has to be suspended.
234 */
235void _Scheduler_EDF_Release_job (
236  const Scheduler_Control *scheduler,
237  Thread_Control          *the_thread,
238  uint32_t                 deadline
239);
240
241#ifdef __cplusplus
242}
243#endif
244
245/**@}*/
246
247#endif
248/* end of include file */
Note: See TracBrowser for help on using the repository browser.