source: rtems/cpukit/score/include/rtems/score/schedulerpriority.h @ 961669d

4.115
Last change on this file since 961669d was 961669d, checked in by Sebastian Huber <sebastian.huber@…>, on 06/14/13 at 13:30:37

documentation: Fix Doxygen comments

  • Property mode set to 100644
File size: 7.1 KB
Line 
1/**
2 *  @file  rtems/score/schedulerpriority.h
3 *
4 *  @brief Thread Manipulation with the Priority-Based Scheduler
5 *
6 *  This include file contains all the constants and structures associated
7 *  with the manipulation of threads for the priority-based scheduler.
8 */
9
10/*
11 *  Copryight (c) 2010 Gedare Bloom.
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_SCHEDULERPRIORITY_H
20#define _RTEMS_SCORE_SCHEDULERPRIORITY_H
21
22#include <rtems/score/chain.h>
23#include <rtems/score/priority.h>
24#include <rtems/score/scheduler.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @defgroup ScoreSchedulerDPS Deterministic Priority-based Scheduler
32 *
33 * @ingroup ScoreScheduler
34 */
35/**@{*/
36
37/**
38 *  Entry points for the Deterministic Priority Based Scheduler.
39 */
40#define SCHEDULER_PRIORITY_ENTRY_POINTS \
41  { \
42    _Scheduler_priority_Initialize,       /* initialize entry point */ \
43    _Scheduler_priority_Schedule,         /* schedule entry point */ \
44    _Scheduler_priority_Yield,            /* yield entry point */ \
45    _Scheduler_priority_Block,            /* block entry point */ \
46    _Scheduler_priority_Unblock,          /* unblock entry point */ \
47    _Scheduler_priority_Allocate,         /* allocate entry point */ \
48    _Scheduler_priority_Free,             /* free entry point */ \
49    _Scheduler_priority_Update,           /* update entry point */ \
50    _Scheduler_priority_Enqueue,          /* enqueue entry point */ \
51    _Scheduler_priority_Enqueue_first,    /* enqueue_first entry point */ \
52    _Scheduler_priority_Extract,          /* extract entry point */ \
53    _Scheduler_priority_Priority_compare, /* compares two priorities */ \
54    _Scheduler_priority_Release_job,      /* new period of task */ \
55    _Scheduler_default_Tick,              /* tick entry point */ \
56    _Scheduler_default_Start_idle         /* start idle entry point */ \
57  }
58
59/**
60 * Per-thread data related to the _Scheduler_PRIORITY scheduling policy.
61 */
62typedef struct {
63  /** This field points to the Ready FIFO for this thread's priority. */
64  Chain_Control                        *ready_chain;
65
66  /** This field contains precalculated priority map indices. */
67  Priority_bit_map_Information          Priority_map;
68} Scheduler_priority_Per_thread;
69
70/**
71 * @brief Initializes the priority scheduler.
72 * This routine initializes the priority scheduler.
73 */
74void _Scheduler_priority_Initialize(void);
75
76/**
77 *  @brief Removes @a the_thread from the scheduling decision.
78 *
79 *  This routine removes @a the_thread from the scheduling decision,
80 *  that is, removes it from the ready queue.  It performs
81 *  any necessary scheduling operations including the selection of
82 *  a new heir thread.
83 *
84 *  @param[in] the_thread is the thread to be blocked
85 */
86void _Scheduler_priority_Block(
87  Thread_Control    *the_thread
88);
89
90/**
91 *  @brief Sets the heir thread to be the next ready thread.
92 *
93 *  This kernel routine sets the heir thread to be the next ready thread
94 *  by invoking the_scheduler->ready_queue->operations->first().
95 */
96void _Scheduler_priority_Schedule(void);
97
98/**
99 *  @brief Allocates @a the_thread->scheduler.
100 *
101 *  This routine allocates @a the_thread->scheduler.
102 *
103 *  @param[in] the_thread is the thread the scheduler is allocating
104 *             management memory for
105 */
106void * _Scheduler_priority_Allocate(
107  Thread_Control      *the_thread
108);
109
110/**
111 *  @brief Frees @a the_thread->scheduler.
112 *
113 *  This routine frees @a the_thread->scheduler.
114 *
115 *  @param[in] the_thread is the thread whose scheduler specific information
116 *             will be deallocated.
117 */
118void _Scheduler_priority_Free(
119  Thread_Control      *the_thread
120);
121
122/**
123 *  @brief Update the scheduler priority.
124 *  This routine updates @a the_thread->scheduler based on @a the_scheduler
125 *  structures and thread state.
126 *
127 *  @param[in] the_thread will have its scheduler specific information
128 *             structure updated.
129 */
130void _Scheduler_priority_Update(
131  Thread_Control      *the_thread
132);
133
134/**
135 *  @brief Add @a the_thread to the scheduling decision.
136 *
137 *  This routine adds @a the_thread to the scheduling decision,
138 *  that is, adds it to the ready queue and
139 *  updates any appropriate scheduling variables, for example the heir thread.
140 *
141 *  @param[in] the_thread will be unblocked
142 */
143void _Scheduler_priority_Unblock(
144  Thread_Control    *the_thread
145);
146
147/**
148 *  @brief The specified THREAD yields.
149 *
150 *  This routine is invoked when a thread wishes to voluntarily
151 *  transfer control of the processor to another thread in the queue.
152 *
153 *  This routine will remove the specified THREAD from the ready queue
154 *  and place it immediately at the rear of this chain.  Reset timeslice
155 *  and yield the processor functions both use this routine, therefore if
156 *  reset is true and this is the only thread on the queue then the
157 *  timeslice counter is reset.  The heir THREAD will be updated if the
158 *  running is also the currently the heir.
159 *
160 *  - INTERRUPT LATENCY:
161 *    + ready chain
162 *    + select heir
163 *
164 *  @param[in,out] thread The yielding thread.
165 */
166void _Scheduler_priority_Yield( Thread_Control *thread );
167
168/**
169 *  @brief Puts @a the_thread on to the priority-based ready queue.
170 *
171 *  This routine puts @a the_thread on to the priority-based ready queue.
172 *
173 *  @param[in] the_thread will be enqueued at the TAIL of its priority.
174 */
175void _Scheduler_priority_Enqueue(
176  Thread_Control    *the_thread
177);
178
179/**
180 *  @brief Puts @a the_thread to the head of the ready queue.
181 *
182 *  This routine puts @a the_thread to the head of the ready queue.
183 *  For priority-based ready queues, the thread will be the first thread
184 *  at its priority level.
185 *
186 *  @param[in] the_thread will be enqueued at the HEAD of its priority.
187 */
188void _Scheduler_priority_Enqueue_first(
189  Thread_Control    *the_thread
190);
191
192/**
193 *  @brief Remove a specific thread from scheduler.
194 *
195 *  This routine removes a specific thread from the scheduler's set
196 *  of ready threads.
197 *
198 *  @param[in] the_thread will be extracted from the ready set.
199 */
200void _Scheduler_priority_Extract(
201  Thread_Control     *the_thread
202);
203
204/**
205 *  @brief Compare two priorities.
206 *
207 *  This routine compares two priorities.
208 */
209int _Scheduler_priority_Priority_compare(
210  Priority_Control      p1,
211  Priority_Control      p2
212);
213
214/**
215 *  @brief Called when a new job of task is released.
216 *
217 *  This routine is called when a new job of task is released.
218 *
219 *  @param[in] the_thread is the owner of the job.
220 *  @param[in] deadline of the new job from now. If equal to 0,
221 *             the job was cancelled or deleted.
222 */
223void _Scheduler_priority_Release_job (
224  Thread_Control  *the_thread,
225  uint32_t         deadline
226);
227
228/**
229 *  This is the major bit map.
230 */
231extern volatile Priority_bit_map_Control _Priority_Major_bit_map;
232
233/**
234 *  This is the minor bit map.
235 */
236extern Priority_bit_map_Control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
237
238#ifndef __RTEMS_APPLICATION__
239#include <rtems/score/schedulerpriority.inl>
240#endif
241
242#ifdef __cplusplus
243}
244#endif
245
246/**@}*/
247
248#endif
249/* end of include file */
Note: See TracBrowser for help on using the repository browser.