source: rtems/cpukit/score/include/rtems/score/scheduleredf.h @ 8568341

4.115
Last change on this file since 8568341 was 8568341, checked in by Sebastian Huber <sebastian.huber@…>, on 06/11/14 at 12:31:03

score: Need for help indicator for scheduler ops

Return a thread in need for help for the following scheduler operations

  • unblock,
  • change priority, and
  • yield.

A thread in need for help is a thread that encounters a scheduler state
change from scheduled to ready or a thread that cannot be scheduled in
an unblock operation. Such a thread can ask threads which depend on
resources owned by this thread for help.

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