source: rtems/cpukit/score/include/rtems/score/schedulerpriority.h @ 24934e36

4.115
Last change on this file since 24934e36 was 24934e36, checked in by Sebastian Huber <sebastian.huber@…>, on 04/03/14 at 13:03:35

score: Add scheduler control to scheduler ops

Scheduler operations must be free of a global scheduler context to
enable partitioned/clustered scheduling.

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