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

4.115
Last change on this file since 1ccb64e1 was 1ccb64e1, checked in by Sebastian Huber <sebastian.huber@…>, on 06/06/13 at 13:28:41

scheduler: Add start idle thread operation

Add and use _Scheduler_Start_idle().

  • 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 running THREAD from the ready queue
193 *  and place back. The rbtree ready queue is responsible for FIFO ordering
194 *  in such a case.
195 */
196void _Scheduler_EDF_Yield( void );
197
198/**
199 *  @brief Put @a the_thread to the rbtree ready queue.
200 *
201 *  This routine puts @a the_thread to the rbtree ready queue.
202 *
203 *  @param[in] the_thread will be enqueued to the ready queue.
204 */
205void _Scheduler_EDF_Enqueue(
206  Thread_Control    *the_thread
207);
208
209/**
210 *  @brief Enqueue a thread to the ready queue.
211 *
212 *  This routine puts @a the_thread to the rbtree ready queue.
213 *  For the EDF scheduler this is the same as @a _Scheduler_EDF_Enqueue.
214 *
215 *  @param[in] the_thread will be enqueued to the ready queue.
216 */
217void _Scheduler_EDF_Enqueue_first(
218  Thread_Control    *the_thread
219);
220
221/**
222 *  @brief Remove a specific thread from the scheduler's set
223 *  of ready threads.
224 *
225 *  This routine removes a specific thread from the scheduler's set
226 *  of ready threads.
227 *
228 *  @param[in] the_thread will be extracted from the ready set.
229 */
230void _Scheduler_EDF_Extract(
231  Thread_Control     *the_thread
232);
233
234/**
235 *  @brief Explicitly compare absolute dedlines (priorities) of threads.
236 *
237 * This routine explicitly compares absolute dedlines (priorities) of threads.
238 * In case of EDF scheduling time overflow is taken into account.
239 *
240 * @retval >0 for p1 > p2; 0 for p1 == p2; <0 for p1 < p2.
241 */
242int _Scheduler_EDF_Priority_compare (
243  Priority_Control p1,
244  Priority_Control p2
245);
246
247/**
248 *  @brief Called when a new job of task is released.
249 *
250 *  This routine is called when a new job of task is released.
251 *  It is called only from Rate Monotonic manager in the beginning
252 *  of new period.
253 *
254 *  @param[in] the_thread is the owner of the job.
255 *  @param[in] deadline of the new job from now. If equal to 0,
256 *             the job was cancelled or deleted, thus a running task
257 *             has to be suspended.
258 */
259void _Scheduler_EDF_Release_job (
260  Thread_Control  *the_thread,
261  uint32_t         deadline
262);
263
264#ifdef __cplusplus
265}
266#endif
267
268/**@}*/
269
270#endif
271/* end of include file */
Note: See TracBrowser for help on using the repository browser.