1 | /** |
---|
2 | * @file rtems/score/schedulersimple.h |
---|
3 | * |
---|
4 | * @brief Manipulation of Threads Simple-Priority-Based Ready Queue |
---|
5 | * |
---|
6 | * This include file contains all the constants and structures associated |
---|
7 | * with the manipulation of threads on a simple-priority-based ready queue. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_H |
---|
19 | #define _RTEMS_SCORE_SCHEDULERSIMPLE_H |
---|
20 | |
---|
21 | #include <rtems/score/scheduler.h> |
---|
22 | #include <rtems/score/schedulerpriority.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup ScoreSchedulerSimple Simple Priority Scheduler |
---|
30 | * |
---|
31 | * @ingroup ScoreScheduler |
---|
32 | */ |
---|
33 | /**@{*/ |
---|
34 | |
---|
35 | /** |
---|
36 | * Entry points for Scheduler Simple |
---|
37 | */ |
---|
38 | #define SCHEDULER_SIMPLE_ENTRY_POINTS \ |
---|
39 | { \ |
---|
40 | _Scheduler_simple_Initialize, /* initialize entry point */ \ |
---|
41 | _Scheduler_simple_Schedule, /* schedule entry point */ \ |
---|
42 | _Scheduler_simple_Yield, /* yield entry point */ \ |
---|
43 | _Scheduler_simple_Block, /* block entry point */ \ |
---|
44 | _Scheduler_simple_Unblock, /* unblock entry point */ \ |
---|
45 | _Scheduler_default_Allocate, /* allocate entry point */ \ |
---|
46 | _Scheduler_default_Free, /* free entry point */ \ |
---|
47 | _Scheduler_default_Update, /* update entry point */ \ |
---|
48 | _Scheduler_simple_Enqueue, /* enqueue entry point */ \ |
---|
49 | _Scheduler_simple_Enqueue_first, /* enqueue_first entry point */ \ |
---|
50 | _Scheduler_simple_Extract, /* extract entry point */ \ |
---|
51 | _Scheduler_priority_Priority_compare, /* compares two priorities */ \ |
---|
52 | _Scheduler_default_Release_job, /* new period of task */ \ |
---|
53 | _Scheduler_default_Tick, /* tick entry point */ \ |
---|
54 | _Scheduler_default_Start_idle /* start idle entry point */ \ |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * @brief Simple scheduler context. |
---|
59 | */ |
---|
60 | typedef struct { |
---|
61 | /** |
---|
62 | * @brief Basic scheduler context. |
---|
63 | */ |
---|
64 | Scheduler_Context Base; |
---|
65 | |
---|
66 | /** |
---|
67 | * @brief One ready queue for all ready threads. |
---|
68 | */ |
---|
69 | Chain_Control Ready; |
---|
70 | } Scheduler_simple_Context; |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief Initialize simple scheduler. |
---|
74 | * |
---|
75 | * This routine initializes the simple scheduler. |
---|
76 | */ |
---|
77 | void _Scheduler_simple_Initialize( const Scheduler_Control *scheduler ); |
---|
78 | |
---|
79 | /** |
---|
80 | * This routine sets the heir thread to be the next ready thread |
---|
81 | * on the ready queue by getting the first node in the scheduler |
---|
82 | * information. |
---|
83 | */ |
---|
84 | void _Scheduler_simple_Schedule( |
---|
85 | const Scheduler_Control *scheduler, |
---|
86 | Thread_Control *the_thread |
---|
87 | ); |
---|
88 | |
---|
89 | /** |
---|
90 | * @brief Invoked when a thread wishes to voluntarily |
---|
91 | * transfer control of the processor to another thread in the queue. |
---|
92 | * |
---|
93 | * This routine is invoked when a thread wishes to voluntarily |
---|
94 | * transfer control of the processor to another thread in the queue. |
---|
95 | * It will remove the specified THREAD from the scheduler.informaiton |
---|
96 | * (where the ready queue is stored) and place it immediately at the |
---|
97 | * between the last entry of its priority and the next priority thread. |
---|
98 | * Reset timeslice and yield the processor functions both use this routine, |
---|
99 | * therefore if reset is true and this is the only thread on the queue then |
---|
100 | * the timeslice counter is reset. The heir THREAD will be updated if the |
---|
101 | * running is also the currently the heir. |
---|
102 | * |
---|
103 | * @param[in,out] thread The yielding thread. |
---|
104 | */ |
---|
105 | void _Scheduler_simple_Yield( |
---|
106 | const Scheduler_Control *scheduler, |
---|
107 | Thread_Control *the_thread |
---|
108 | ); |
---|
109 | |
---|
110 | /** |
---|
111 | * @brief Remove a simple-priority-based thread from the queue. |
---|
112 | * |
---|
113 | * This routine removes @a the_thread from the scheduling decision, |
---|
114 | * that is, removes it from the ready queue. It performs |
---|
115 | * any necessary scheduling operations including the selection of |
---|
116 | * a new heir thread. |
---|
117 | * |
---|
118 | * @param[in] the_thread is the thread that is to be blocked |
---|
119 | */ |
---|
120 | void _Scheduler_simple_Block( |
---|
121 | const Scheduler_Control *scheduler, |
---|
122 | Thread_Control *the_thread |
---|
123 | ); |
---|
124 | |
---|
125 | /** |
---|
126 | * @brief Unblock a simple-priority-based thread. |
---|
127 | * |
---|
128 | * This routine adds @a the_thread to the scheduling decision, |
---|
129 | * that is, adds it to the ready queue and |
---|
130 | * updates any appropriate scheduling variables, for example the heir thread. |
---|
131 | * |
---|
132 | * @param[in] the_thread is the thread that is to be unblocked |
---|
133 | */ |
---|
134 | void _Scheduler_simple_Unblock( |
---|
135 | const Scheduler_Control *scheduler, |
---|
136 | Thread_Control *the_thread |
---|
137 | ); |
---|
138 | |
---|
139 | /** |
---|
140 | * @brief Removes a simple-priority-based thread from a simple queue. |
---|
141 | * |
---|
142 | * This routine removes a specific thread from the specified |
---|
143 | * simple-based ready queue. |
---|
144 | * |
---|
145 | * @param[in] the_thread is the thread to be blocked |
---|
146 | */ |
---|
147 | void _Scheduler_simple_Extract( |
---|
148 | const Scheduler_Control *scheduler, |
---|
149 | Thread_Control *the_thread |
---|
150 | ); |
---|
151 | |
---|
152 | /** |
---|
153 | * @brief Puts simple-priority-based thread onto the ready queue. |
---|
154 | * |
---|
155 | * This routine puts @a the_thread on to the ready queue. |
---|
156 | * |
---|
157 | * @param[in] the_thread is the thread to be enqueued |
---|
158 | */ |
---|
159 | void _Scheduler_simple_Enqueue( |
---|
160 | const Scheduler_Control *scheduler, |
---|
161 | Thread_Control *the_thread |
---|
162 | ); |
---|
163 | |
---|
164 | /** |
---|
165 | * @brief Put simple-priority-based @a the_thread to |
---|
166 | * the head of the ready queue. |
---|
167 | * |
---|
168 | * This routine puts @a the_thread to the head of the ready queue. |
---|
169 | * The thread will be the first thread at its priority level. |
---|
170 | * |
---|
171 | * @param[in] the_thread is the thread to be blocked |
---|
172 | */ |
---|
173 | void _Scheduler_simple_Enqueue_first( |
---|
174 | const Scheduler_Control *scheduler, |
---|
175 | Thread_Control *the_thread |
---|
176 | ); |
---|
177 | |
---|
178 | /** |
---|
179 | * _Scheduler_simple_Ready_queue_enqueue |
---|
180 | * |
---|
181 | * This routine puts @a the_thread on the ready queue |
---|
182 | * at the end of its priority group. |
---|
183 | * |
---|
184 | * @param[in] the_thread - pointer to a thread control block |
---|
185 | */ |
---|
186 | void _Scheduler_simple_Ready_queue_enqueue( |
---|
187 | const Scheduler_Control *scheduler, |
---|
188 | Thread_Control *the_thread |
---|
189 | ); |
---|
190 | |
---|
191 | /** |
---|
192 | * @brief Puts simple-priority-based @a the_thread on to the ready queue |
---|
193 | * at the beginning of its priority group. |
---|
194 | * |
---|
195 | * This routine puts @a the_thread on to the ready queue |
---|
196 | * at the beginning of its priority group. |
---|
197 | * |
---|
198 | * @param[in] the_thread - pointer to a thread control block |
---|
199 | */ |
---|
200 | void _Scheduler_simple_Ready_queue_enqueue_first( |
---|
201 | const Scheduler_Control *scheduler, |
---|
202 | Thread_Control *the_thread |
---|
203 | ); |
---|
204 | |
---|
205 | /**@}*/ |
---|
206 | |
---|
207 | #ifdef __cplusplus |
---|
208 | } |
---|
209 | #endif |
---|
210 | |
---|
211 | #endif |
---|
212 | /* end of include file */ |
---|