source: rtems/cpukit/score/include/rtems/score/scheduleredf.h @ 6eba7c85

4.115
Last change on this file since 6eba7c85 was 6eba7c85, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 10, 2013 at 2:15:46 PM

scheduler: Specify thread of yield operation

The yielding thread of the yield operation is now specified by a
parameter. The tick operation may be performed for each executing
thread in a SMP configuration.

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