source: rtems/cpukit/score/include/rtems/score/schedulerpriority.h @ e1598a6

4.115
Last change on this file since e1598a6 was e1598a6, checked in by Sebastian Huber <sebastian.huber@…>, on 04/04/14 at 08:56:36

score: Static scheduler configuration

Do not allocate the scheduler control structures from the workspace.
This is a preparation step for configuration of clustered/partitioned
schedulers on SMP.

  • Property mode set to 100644
File size: 7.6 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.org/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/prioritybitmap.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#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
38  #define SCHEDULER_PRIORITY_ADDITIONAL_SMP_ENTRY_POINTS \
39    _Scheduler_default_Get_affinity,     /* get affinity entry point */ \
40    _Scheduler_default_Set_affinity      /* set affinity entry point */
41#else
42  #define SCHEDULER_PRIORITY_ADDITIONAL_SMP_ENTRY_POINTS
43#endif
44
45/**
46 *  Entry points for the Deterministic Priority Based Scheduler.
47 */
48#define SCHEDULER_PRIORITY_ENTRY_POINTS \
49  { \
50    _Scheduler_priority_Initialize,       /* initialize entry point */ \
51    _Scheduler_priority_Schedule,         /* schedule entry point */ \
52    _Scheduler_priority_Yield,            /* yield entry point */ \
53    _Scheduler_priority_Block,            /* block entry point */ \
54    _Scheduler_priority_Unblock,          /* unblock entry point */ \
55    _Scheduler_priority_Allocate,         /* allocate entry point */ \
56    _Scheduler_priority_Free,             /* free entry point */ \
57    _Scheduler_priority_Update,           /* update entry point */ \
58    _Scheduler_priority_Enqueue,          /* enqueue entry point */ \
59    _Scheduler_priority_Enqueue_first,    /* enqueue_first entry point */ \
60    _Scheduler_priority_Extract,          /* extract entry point */ \
61    _Scheduler_priority_Priority_compare, /* compares two priorities */ \
62    _Scheduler_default_Release_job,       /* new period of task */ \
63    _Scheduler_default_Tick,              /* tick entry point */ \
64    _Scheduler_default_Start_idle,        /* start idle entry point */ \
65    SCHEDULER_PRIORITY_ADDITIONAL_SMP_ENTRY_POINTS \
66  }
67
68typedef struct {
69  /**
70   * @brief Basic scheduler context.
71   */
72  Scheduler_Context Base;
73
74  /**
75   * @brief Bit map to indicate non-empty ready queues.
76   */
77  Priority_bit_map_Control Bit_map;
78
79  /**
80   * @brief One ready queue per priority level.
81   */
82  Chain_Control Ready[ 0 ];
83} Scheduler_priority_Context;
84
85/**
86 * Per-thread data related to the _Scheduler_PRIORITY scheduling policy.
87 */
88typedef struct {
89  /** This field points to the Ready FIFO for this thread's priority. */
90  Chain_Control                        *ready_chain;
91
92  /** This field contains precalculated priority map indices. */
93  Priority_bit_map_Information          Priority_map;
94} Scheduler_priority_Per_thread;
95
96/**
97 * @brief Initializes the priority scheduler.
98 * This routine initializes the priority scheduler.
99 */
100void _Scheduler_priority_Initialize( const Scheduler_Control *scheduler );
101
102/**
103 *  @brief Removes @a the_thread from the scheduling decision.
104 *
105 *  This routine removes @a the_thread from the scheduling decision,
106 *  that is, removes it from the ready queue.  It performs
107 *  any necessary scheduling operations including the selection of
108 *  a new heir thread.
109 *
110 *  @param[in] the_thread is the thread to be blocked
111 */
112void _Scheduler_priority_Block(
113  const Scheduler_Control *scheduler,
114  Thread_Control          *the_thread
115);
116
117/**
118 *  @brief Sets the heir thread to be the next ready thread.
119 *
120 *  This kernel routine sets the heir thread to be the next ready thread
121 *  by invoking the_scheduler->ready_queue->operations->first().
122 */
123void _Scheduler_priority_Schedule(
124  const Scheduler_Control *scheduler,
125  Thread_Control          *the_thread
126);
127
128/**
129 *  @brief Allocates @a the_thread->scheduler.
130 *
131 *  This routine allocates @a the_thread->scheduler.
132 *
133 *  @param[in] the_thread is the thread the scheduler is allocating
134 *             management memory for
135 */
136void * _Scheduler_priority_Allocate(
137  const Scheduler_Control *scheduler,
138  Thread_Control          *the_thread
139);
140
141/**
142 *  @brief Frees @a the_thread->scheduler.
143 *
144 *  This routine frees @a the_thread->scheduler.
145 *
146 *  @param[in] the_thread is the thread whose scheduler specific information
147 *             will be deallocated.
148 */
149void _Scheduler_priority_Free(
150  const Scheduler_Control *scheduler,
151  Thread_Control          *the_thread
152);
153
154/**
155 *  @brief Update the scheduler priority.
156 *  This routine updates @a the_thread->scheduler based on @a the_scheduler
157 *  structures and thread state.
158 *
159 *  @param[in] the_thread will have its scheduler specific information
160 *             structure updated.
161 */
162void _Scheduler_priority_Update(
163  const Scheduler_Control *scheduler,
164  Thread_Control          *the_thread
165);
166
167/**
168 *  @brief Add @a the_thread to the scheduling decision.
169 *
170 *  This routine adds @a the_thread to the scheduling decision,
171 *  that is, adds it to the ready queue and
172 *  updates any appropriate scheduling variables, for example the heir thread.
173 *
174 *  @param[in] the_thread will be unblocked
175 */
176void _Scheduler_priority_Unblock(
177  const Scheduler_Control *scheduler,
178  Thread_Control          *the_thread
179);
180
181/**
182 *  @brief The specified THREAD yields.
183 *
184 *  This routine is invoked when a thread wishes to voluntarily
185 *  transfer control of the processor to another thread in the queue.
186 *
187 *  This routine will remove the specified THREAD from the ready queue
188 *  and place it immediately at the rear of this chain.  Reset timeslice
189 *  and yield the processor functions both use this routine, therefore if
190 *  reset is true and this is the only thread on the queue then the
191 *  timeslice counter is reset.  The heir THREAD will be updated if the
192 *  running is also the currently the heir.
193 *
194 *  - INTERRUPT LATENCY:
195 *    + ready chain
196 *    + select heir
197 *
198 *  @param[in,out] thread The yielding thread.
199 */
200void _Scheduler_priority_Yield(
201  const Scheduler_Control *scheduler,
202  Thread_Control          *the_thread
203);
204
205/**
206 *  @brief Puts @a the_thread on to the priority-based ready queue.
207 *
208 *  This routine puts @a the_thread on to the priority-based ready queue.
209 *
210 *  @param[in] the_thread will be enqueued at the TAIL of its priority.
211 */
212void _Scheduler_priority_Enqueue(
213  const Scheduler_Control *scheduler,
214  Thread_Control          *the_thread
215);
216
217/**
218 *  @brief Puts @a the_thread to the head of the ready queue.
219 *
220 *  This routine puts @a the_thread to the head of the ready queue.
221 *  For priority-based ready queues, the thread will be the first thread
222 *  at its priority level.
223 *
224 *  @param[in] the_thread will be enqueued at the HEAD of its priority.
225 */
226void _Scheduler_priority_Enqueue_first(
227  const Scheduler_Control *scheduler,
228  Thread_Control          *the_thread
229);
230
231/**
232 *  @brief Remove a specific thread from scheduler.
233 *
234 *  This routine removes a specific thread from the scheduler's set
235 *  of ready threads.
236 *
237 *  @param[in] the_thread will be extracted from the ready set.
238 */
239void _Scheduler_priority_Extract(
240  const Scheduler_Control *scheduler,
241  Thread_Control          *the_thread
242);
243
244/**
245 *  @brief Compare two priorities.
246 *
247 *  This routine compares two priorities.
248 */
249int _Scheduler_priority_Priority_compare(
250  Priority_Control   p1,
251  Priority_Control   p2
252);
253
254/**@}*/
255
256#ifdef __cplusplus
257}
258#endif
259
260#endif
261/* end of include file */
Note: See TracBrowser for help on using the repository browser.