source: rtems/cpukit/score/include/rtems/score/scheduleredf.h @ 1c77a36

5
Last change on this file since 1c77a36 was 50a56dff, checked in by Sebastian Huber <sebastian.huber@…>, on 06/24/16 at 09:16:35

score: Move SCHEDULER_EDF_PRIO_MSB

This is an implementation detail of the EDF scheduler.

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