1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-2011. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | |
---|
6 | @chapter Scheduling Concepts |
---|
7 | |
---|
8 | @cindex scheduling |
---|
9 | @cindex task scheduling |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The concept of scheduling in real-time systems dictates the ability to |
---|
14 | provide immediate response to specific external events, particularly |
---|
15 | the necessity of scheduling tasks to run within a specified time limit |
---|
16 | after the occurrence of an event. For example, software embedded in |
---|
17 | life-support systems used to monitor hospital patients must take instant |
---|
18 | action if a change in the patient's status is detected. |
---|
19 | |
---|
20 | The component of RTEMS responsible for providing this capability is |
---|
21 | appropriately called the scheduler. The scheduler's sole purpose is |
---|
22 | to allocate the all important resource of processor time to the various |
---|
23 | tasks competing for attention. |
---|
24 | |
---|
25 | @section Scheduling Algorithms |
---|
26 | |
---|
27 | @cindex scheduling algorithms |
---|
28 | |
---|
29 | RTEMS provides a plugin framework which allows it to support |
---|
30 | multiple scheduling algorithms. RTEMS now includes multiple |
---|
31 | scheduling algorithms in the SuperCore and the user can select which |
---|
32 | of these they wish to use in their application. In addition, |
---|
33 | the user can implement their own scheduling algorithm and |
---|
34 | configure RTEMS to use it. |
---|
35 | |
---|
36 | Supporting multiple scheduling algorithms gives the end user the |
---|
37 | option to select the algorithm which is most appropriate to their use |
---|
38 | case. Most real-time operating systems schedule tasks using a priority |
---|
39 | based algorithm, possibly with preemption control. The classic |
---|
40 | RTEMS scheduling algorithm which was the only algorithm available |
---|
41 | in RTEMS 4.10 and earlier, is a priority based scheduling algorithm. |
---|
42 | This scheduling algoritm is suitable for single core (e.g. non-SMP) |
---|
43 | systems and is now known as the @b{Deterministic Priority Scheduler}. |
---|
44 | Unless the user configures another scheduling algorithm, RTEMS will use |
---|
45 | this on single core systems. |
---|
46 | |
---|
47 | @subsection Priority Scheduling |
---|
48 | |
---|
49 | @cindex priority scheduling |
---|
50 | |
---|
51 | When using priority based scheduling, RTEMS allocates the processor using |
---|
52 | a priority-based, preemptive algorithm augmented to provide round-robin |
---|
53 | characteristics within individual priority groups. The goal of this |
---|
54 | algorithm is to guarantee that the task which is executing on the |
---|
55 | processor at any point in time is the one with the highest priority |
---|
56 | among all tasks in the ready state. |
---|
57 | |
---|
58 | When a task is added to the ready chain, it is placed behind all other |
---|
59 | tasks of the same priority. This rule provides a round-robin within |
---|
60 | priority group scheduling characteristic. This means that in a group of |
---|
61 | equal priority tasks, tasks will execute in the order they become ready |
---|
62 | or FIFO order. Even though there are ways to manipulate and adjust task |
---|
63 | priorities, the most important rule to remember is: |
---|
64 | |
---|
65 | @itemize @code{ } |
---|
66 | @item @b{Priority based scheduling algorithms will always select the |
---|
67 | highest priority task that is ready to run when allocating the processor |
---|
68 | to a task.} |
---|
69 | @end itemize |
---|
70 | |
---|
71 | Priority scheduling is the most commonly used scheduling algorithm. |
---|
72 | It should be used by applications in which multiple tasks contend for |
---|
73 | CPU time or other resources and there is a need to ensure certain tasks |
---|
74 | are given priority over other tasks. |
---|
75 | |
---|
76 | There are a few common methods of accomplishing the mechanics of this |
---|
77 | algorithm. These ways involve a list or chain of tasks in the ready state. |
---|
78 | |
---|
79 | @itemize @bullet |
---|
80 | @item The least efficient method is to randomly place tasks in the ready |
---|
81 | chain forcing the scheduler to scan the entire chain to determine which |
---|
82 | task receives the processor. |
---|
83 | |
---|
84 | @item A more efficient method is to schedule the task by placing it |
---|
85 | in the proper place on the ready chain based on the designated scheduling |
---|
86 | criteria at the time it enters the ready state. Thus, when the processor |
---|
87 | is free, the first task on the ready chain is allocated the processor. |
---|
88 | |
---|
89 | @item Another mechanism is to maintain a list of FIFOs per priority. |
---|
90 | When a task is readied, it is placed on the rear of the FIFO for its |
---|
91 | priority. This method is often used with a bitmap to assist in locating |
---|
92 | which FIFOs have ready tasks on them. |
---|
93 | |
---|
94 | @end itemize |
---|
95 | RTEMS currently includes multiple priority based scheduling algorithms |
---|
96 | as well as other algorithms which incorporate deadline. Each algorithm |
---|
97 | is discussed in the following sections. |
---|
98 | |
---|
99 | @subsection Deterministic Priority Scheduler |
---|
100 | |
---|
101 | This is the scheduler implementation which has always been in RTEMS. |
---|
102 | After the 4.10 release series, it was factored into pluggable scheduler |
---|
103 | selection. It schedules tasks using a priority based algorithm which |
---|
104 | takes into account preemption. It is implemented using an array of FIFOs |
---|
105 | with a FIFO per priority. It maintains a bitmap which is used to track |
---|
106 | which priorities have ready tasks. |
---|
107 | |
---|
108 | This algorithm is deterministic (e.g. predictable and fixed) in execution |
---|
109 | time. This comes at the cost of using slightly over three (3) kilobytes |
---|
110 | of RAM on a system configured to support 256 priority levels. |
---|
111 | |
---|
112 | This scheduler is only aware of a single core. |
---|
113 | |
---|
114 | @subsection Simple Priority Scheduler |
---|
115 | |
---|
116 | This scheduler implementation has the same behaviour as the Deterministic |
---|
117 | Priority Scheduler but uses only one linked list to manage all ready |
---|
118 | tasks. When a task is readied, a linear search of that linked list is |
---|
119 | performed to determine where to insert the newly readied task. |
---|
120 | |
---|
121 | This algorithm uses much less RAM than the Deterministic Priority |
---|
122 | Scheduler but is @i{O(n)} where @i{n} is the number of ready tasks. |
---|
123 | In a small system with a small number of tasks, this will not be a |
---|
124 | performance issue. Reducing RAM consumption is often critical in small |
---|
125 | systems which are incapable of supporting a large number of tasks. |
---|
126 | |
---|
127 | This scheduler is only aware of a single core. |
---|
128 | |
---|
129 | @subsection Simple SMP Priority Scheduler |
---|
130 | |
---|
131 | This scheduler is based upon the Simple Priority Scheduler and is designed |
---|
132 | to have the same behaviour on a single core system. But this scheduler |
---|
133 | is capable of scheduling threads across multiple cores in an SMP system. |
---|
134 | When given a choice of replacing one of two threads at equal priority |
---|
135 | on different cores, this algorithm favors replacing threads which are |
---|
136 | preemptible and have executed the longest. |
---|
137 | |
---|
138 | This algorithm is non-deterministic. When scheduling, it must consider |
---|
139 | which tasks are to be executed on each core while avoiding superfluous |
---|
140 | task migrations. |
---|
141 | |
---|
142 | @subsection Earliest Deadline First Scheduler |
---|
143 | |
---|
144 | @cindex earliest deadline first scheduling |
---|
145 | |
---|
146 | This is an alternative scheduler in RTEMS for single core applications. |
---|
147 | The primary EDF advantage is high total CPU utilization (theoretically |
---|
148 | up to 100%). It assumes that tasks have priorities equal to deadlines. |
---|
149 | |
---|
150 | This EDF is initially preemptive, however, individual tasks may be declared |
---|
151 | not-preemptive. Deadlines are declared using only Rate Monotonic manager which |
---|
152 | goal is to handle periodic behavior. Period is always equal to deadline. All |
---|
153 | ready tasks reside in a single ready queue implemented using a red-black tree. |
---|
154 | |
---|
155 | This implementation of EDF schedules two different types of task |
---|
156 | priority types while each task may switch between the two types within |
---|
157 | its execution. If a task does have a deadline declared using the Rate |
---|
158 | Monotonic manager, the task is deadline-driven and its priority is equal |
---|
159 | to deadline. On the contrary if a task does not have any deadline or |
---|
160 | the deadline is cancelled using the Rate Monotonic manager, the task is |
---|
161 | considered a background task with priority equal to that assigned |
---|
162 | upon initialization in the same manner as for priority scheduler. Each |
---|
163 | background task is of a lower importance than each deadline-driven one |
---|
164 | and is scheduled when no deadline-driven task and no higher priority |
---|
165 | background task is ready to run. |
---|
166 | |
---|
167 | Every deadline-driven scheduling algorithm requires means for tasks |
---|
168 | to claim a deadline. The Rate Monotonic Manager is responsible for |
---|
169 | handling periodic execution. In RTEMS periods are equal to deadlines, |
---|
170 | thus if a task announces a period, it has to be finished until the |
---|
171 | end of this period. The call of @code{rtems_rate_monotonic_period} |
---|
172 | passes the scheduler the length of oncoming deadline. Moreover, the |
---|
173 | @code{rtems_rate_monotonic_cancel} and @code{rtems_rate_monotonic_delete} |
---|
174 | calls clear the deadlines assigned to the task. |
---|
175 | |
---|
176 | @subsection Constant Bandwidth Server Scheduling (CBS) |
---|
177 | |
---|
178 | @cindex constant bandwidth server scheduling |
---|
179 | |
---|
180 | This is an alternative scheduler in RTEMS for single core applications. |
---|
181 | The CBS is a budget aware extension of EDF scheduler. The main goal of this |
---|
182 | scheduler is to ensure temporal isolation of tasks meaning that a task's |
---|
183 | execution in terms of meeting deadlines must not be influenced by other |
---|
184 | tasks as if they were run on multiple independent processors. |
---|
185 | |
---|
186 | Each task can be assigned a server (current implementation supports only |
---|
187 | one task per server). The server is characterized by period (deadline) |
---|
188 | and computation time (budget). The ratio budget/period yields bandwidth, |
---|
189 | which is the fraction of CPU to be reserved by the scheduler for each |
---|
190 | subsequent period. |
---|
191 | |
---|
192 | The CBS is equipped with a set of rules applied to tasks attached to servers |
---|
193 | ensuring that deadline miss because of another task cannot occur. |
---|
194 | In case a task breaks one of the rules, its priority is pulled to background |
---|
195 | until the end of its period and then restored again. The rules are: |
---|
196 | |
---|
197 | @itemize @bullet |
---|
198 | @item Task cannot exceed its registered budget, @item Task cannot be |
---|
199 | unblocked when a ratio between remaining budget and remaining deadline |
---|
200 | is higher than declared bandwidth. |
---|
201 | @end itemize |
---|
202 | |
---|
203 | The CBS provides an extensive API. Unlike EDF, the |
---|
204 | @code{rtems_rate_monotonic_period} does not declare a deadline because |
---|
205 | it is carried out using CBS API. This call only announces next period. |
---|
206 | |
---|
207 | @section Scheduling Modification Mechanisms |
---|
208 | |
---|
209 | @cindex scheduling mechanisms |
---|
210 | |
---|
211 | RTEMS provides four mechanisms which allow the user to alter the task |
---|
212 | scheduling decisions: |
---|
213 | |
---|
214 | @itemize @bullet |
---|
215 | @item user-selectable task priority level |
---|
216 | @item task preemption control |
---|
217 | @item task timeslicing control |
---|
218 | @item manual round-robin selection |
---|
219 | @end itemize |
---|
220 | |
---|
221 | Each of these methods provides a powerful capability to customize sets |
---|
222 | of tasks to satisfy the unique and particular requirements encountered |
---|
223 | in custom real-time applications. Although each mechanism operates |
---|
224 | independently, there is a precedence relationship which governs the |
---|
225 | effects of scheduling modifications. The evaluation order for scheduling |
---|
226 | characteristics is always priority, preemption mode, and timeslicing. |
---|
227 | When reading the descriptions of timeslicing and manual round-robin |
---|
228 | it is important to keep in mind that preemption (if enabled) of a task |
---|
229 | by higher priority tasks will occur as required, overriding the other |
---|
230 | factors presented in the description. |
---|
231 | |
---|
232 | @subsection Task Priority and Scheduling |
---|
233 | |
---|
234 | @cindex task priority |
---|
235 | |
---|
236 | The most significant task scheduling modification mechanism is the ability |
---|
237 | for the user to assign a priority level to each individual task when it |
---|
238 | is created and to alter a task's priority at run-time. RTEMS supports |
---|
239 | up to 255 priority levels. Level 255 is the lowest priority and level |
---|
240 | 1 is the highest. |
---|
241 | |
---|
242 | @subsection Preemption |
---|
243 | @cindex preemption |
---|
244 | |
---|
245 | Another way the user can alter the basic scheduling algorithm is by |
---|
246 | manipulating the preemption mode flag (@code{@value{RPREFIX}PREEMPT_MASK}) |
---|
247 | of individual tasks. If preemption is disabled for a task |
---|
248 | (@code{@value{RPREFIX}NO_PREEMPT}), then the task will not relinquish |
---|
249 | control of the processor until it terminates, blocks, or re-enables |
---|
250 | preemption. Even tasks which become ready to run and possess higher |
---|
251 | priority levels will not be allowed to execute. Note that the preemption |
---|
252 | setting has no effect on the manner in which a task is scheduled. |
---|
253 | It only applies once a task has control of the processor. |
---|
254 | |
---|
255 | @subsection Timeslicing |
---|
256 | @cindex timeslicing |
---|
257 | @cindex round robin scheduling |
---|
258 | |
---|
259 | Timeslicing or round-robin scheduling is an additional method which |
---|
260 | can be used to alter the basic scheduling algorithm. Like preemption, |
---|
261 | timeslicing is specified on a task by task basis using the timeslicing |
---|
262 | mode flag (@code{@value{RPREFIX}TIMESLICE_MASK}). If timeslicing is |
---|
263 | enabled for a task (@code{@value{RPREFIX}TIMESLICE}), then RTEMS will |
---|
264 | limit the amount of time the task can execute before the processor is |
---|
265 | allocated to another task. Each tick of the real-time clock reduces |
---|
266 | the currently running task's timeslice. When the execution time equals |
---|
267 | the timeslice, RTEMS will dispatch another task of the same priority |
---|
268 | to execute. If there are no other tasks of the same priority ready to |
---|
269 | execute, then the current task is allocated an additional timeslice and |
---|
270 | continues to run. Remember that a higher priority task will preempt |
---|
271 | the task (unless preemption is disabled) as soon as it is ready to run, |
---|
272 | even if the task has not used up its entire timeslice. |
---|
273 | |
---|
274 | @subsection Manual Round-Robin |
---|
275 | @cindex manual round robin |
---|
276 | |
---|
277 | The final mechanism for altering the RTEMS scheduling algorithm is |
---|
278 | called manual round-robin. Manual round-robin is invoked by using the |
---|
279 | @code{@value{DIRPREFIX}task_wake_after} directive with a time interval |
---|
280 | of @code{@value{RPREFIX}YIELD_PROCESSOR}. This allows a task to give |
---|
281 | up the processor and be immediately returned to the ready chain at the |
---|
282 | end of its priority group. If no other tasks of the same priority are |
---|
283 | ready to run, then the task does not lose control of the processor. |
---|
284 | |
---|
285 | @section Dispatching Tasks |
---|
286 | @cindex dispatching |
---|
287 | |
---|
288 | The dispatcher is the RTEMS component responsible for |
---|
289 | allocating the processor to a ready task. In order to allocate |
---|
290 | the processor to one task, it must be deallocated or retrieved |
---|
291 | from the task currently using it. This involves a concept |
---|
292 | called a context switch. To perform a context switch, the |
---|
293 | dispatcher saves the context of the current task and restores |
---|
294 | the context of the task which has been allocated to the |
---|
295 | processor. Saving and restoring a task's context is the |
---|
296 | storing/loading of all the essential information about a task to |
---|
297 | enable it to continue execution without any effects of the |
---|
298 | interruption. For example, the contents of a task's register |
---|
299 | set must be the same when it is given the processor as they were |
---|
300 | when it was taken away. All of the information that must be |
---|
301 | saved or restored for a context switch is located either in the |
---|
302 | TCB or on the task's stacks. |
---|
303 | |
---|
304 | Tasks that utilize a numeric coprocessor and are created with the |
---|
305 | @code{@value{RPREFIX}FLOATING_POINT} attribute require additional |
---|
306 | operations during a context switch. These additional operations |
---|
307 | are necessary to save and restore the floating point context of |
---|
308 | @code{@value{RPREFIX}FLOATING_POINT} tasks. To avoid unnecessary save |
---|
309 | and restore operations, the state of the numeric coprocessor is only |
---|
310 | saved when a @code{@value{RPREFIX}FLOATING_POINT} task is dispatched |
---|
311 | and that task was not the last task to utilize the coprocessor. |
---|
312 | |
---|
313 | @section Task State Transitions |
---|
314 | @cindex task state transitions |
---|
315 | |
---|
316 | Tasks in an RTEMS system must always be in one of the |
---|
317 | five allowable task states. These states are: executing, ready, |
---|
318 | blocked, dormant, and non-existent. |
---|
319 | |
---|
320 | A task occupies the non-existent state before |
---|
321 | a @code{@value{DIRPREFIX}task_create} has been issued on its behalf. |
---|
322 | A task enters the non-existent state from any other state in the system |
---|
323 | when it is deleted with the @code{@value{DIRPREFIX}task_delete} directive. |
---|
324 | While a task occupies this state it does not have a TCB or a task ID |
---|
325 | assigned to it; therefore, no other tasks in the system may reference |
---|
326 | this task. |
---|
327 | |
---|
328 | When a task is created via the @code{@value{DIRPREFIX}task_create} |
---|
329 | directive it enters the dormant state. This state is not entered through |
---|
330 | any other means. Although the task exists in the system, it cannot |
---|
331 | actively compete for system resources. It will remain in the dormant |
---|
332 | state until it is started via the @code{@value{DIRPREFIX}task_start} |
---|
333 | directive, at which time it enters the ready state. The task is now |
---|
334 | permitted to be scheduled for the processor and to compete for other |
---|
335 | system resources. |
---|
336 | |
---|
337 | @float Figure,fig:RTEMS-Task-States |
---|
338 | @caption{RTEMS Task States} |
---|
339 | |
---|
340 | @ifset use-ascii |
---|
341 | @example |
---|
342 | @group |
---|
343 | +-------------------------------------------------------------+ |
---|
344 | | Non-existent | |
---|
345 | | +-------------------------------------------------------+ | |
---|
346 | | | | | |
---|
347 | | | | | |
---|
348 | | | Creating +---------+ Deleting | | |
---|
349 | | | -------------------> | Dormant | -------------------> | | |
---|
350 | | | +---------+ | | |
---|
351 | | | | | | |
---|
352 | | | Starting | | | |
---|
353 | | | | | | |
---|
354 | | | V Deleting | | |
---|
355 | | | +-------> +-------+ -------------------> | | |
---|
356 | | | Yielding / +----- | Ready | ------+ | | |
---|
357 | | | / / +-------+ <--+ \ | | |
---|
358 | | | / / \ \ Blocking | | |
---|
359 | | | / / Dispatching Readying \ \ | | |
---|
360 | | | / V \ V | | |
---|
361 | | | +-----------+ Blocking +---------+ | | |
---|
362 | | | | Executing | --------------> | Blocked | | | |
---|
363 | | | +-----------+ +---------+ | | |
---|
364 | | | | | |
---|
365 | | | | | |
---|
366 | | +-------------------------------------------------------+ | |
---|
367 | | Non-existent | |
---|
368 | +-------------------------------------------------------------+ |
---|
369 | @end group |
---|
370 | @end example |
---|
371 | @end ifset |
---|
372 | |
---|
373 | @ifset use-tex |
---|
374 | @c @page |
---|
375 | @example |
---|
376 | @center{@image{states,,3in,RTEMS Task States}} |
---|
377 | @end example |
---|
378 | @end ifset |
---|
379 | |
---|
380 | @ifset use-html |
---|
381 | @html |
---|
382 | <IMG SRC="states.png" WIDTH=550 HEIGHT=400 ALT="RTEMS Task States"> |
---|
383 | @end html |
---|
384 | @end ifset |
---|
385 | @end float |
---|
386 | |
---|
387 | A task occupies the blocked state whenever it is unable to be scheduled |
---|
388 | to run. A running task may block itself or be blocked by other tasks in |
---|
389 | the system. The running task blocks itself through voluntary operations |
---|
390 | that cause the task to wait. The only way a task can block a task other |
---|
391 | than itself is with the @code{@value{DIRPREFIX}task_suspend} directive. |
---|
392 | A task enters the blocked state due to any of the following conditions: |
---|
393 | |
---|
394 | @itemize @bullet |
---|
395 | @item A task issues a @code{@value{DIRPREFIX}task_suspend} directive |
---|
396 | which blocks either itself or another task in the system. |
---|
397 | |
---|
398 | @item The running task issues a @code{@value{DIRPREFIX}barrier_wait} |
---|
399 | directive. |
---|
400 | |
---|
401 | @item The running task issues a @code{@value{DIRPREFIX}message_queue_receive} |
---|
402 | directive with the wait option and the message queue is empty. |
---|
403 | |
---|
404 | @item The running task issues an @code{@value{DIRPREFIX}event_receive} |
---|
405 | directive with the wait option and the currently pending events do not |
---|
406 | satisfy the request. |
---|
407 | |
---|
408 | @item The running task issues a @code{@value{DIRPREFIX}semaphore_obtain} |
---|
409 | directive with the wait option and the requested semaphore is unavailable. |
---|
410 | |
---|
411 | @item The running task issues a @code{@value{DIRPREFIX}task_wake_after} |
---|
412 | directive which blocks the task for the given time interval. If the time |
---|
413 | interval specified is zero, the task yields the processor and remains |
---|
414 | in the ready state. |
---|
415 | |
---|
416 | @item The running task issues a @code{@value{DIRPREFIX}task_wake_when} |
---|
417 | directive which blocks the task until the requested date and time arrives. |
---|
418 | |
---|
419 | @item The running task issues a @code{@value{DIRPREFIX}rate_monotonic_period} |
---|
420 | directive and must wait for the specified rate monotonic period |
---|
421 | to conclude. |
---|
422 | |
---|
423 | @item The running task issues a @code{@value{DIRPREFIX}region_get_segment} |
---|
424 | directive with the wait option and there is not an available segment large |
---|
425 | enough to satisfy the task's request. |
---|
426 | |
---|
427 | @end itemize |
---|
428 | |
---|
429 | A blocked task may also be suspended. Therefore, both the suspension |
---|
430 | and the blocking condition must be removed before the task becomes ready |
---|
431 | to run again. |
---|
432 | |
---|
433 | A task occupies the ready state when it is able to be scheduled to run, |
---|
434 | but currently does not have control of the processor. Tasks of the same |
---|
435 | or higher priority will yield the processor by either becoming blocked, |
---|
436 | completing their timeslice, or being deleted. All tasks with the same |
---|
437 | priority will execute in FIFO order. A task enters the ready state due |
---|
438 | to any of the following conditions: |
---|
439 | |
---|
440 | @itemize @bullet |
---|
441 | |
---|
442 | @item A running task issues a @code{@value{DIRPREFIX}task_resume} |
---|
443 | directive for a task that is suspended and the task is not blocked |
---|
444 | waiting on any resource. |
---|
445 | |
---|
446 | @item A running task issues a @code{@value{DIRPREFIX}message_queue_send}, |
---|
447 | @code{@value{DIRPREFIX}message_queue_broadcast}, or a |
---|
448 | @code{@value{DIRPREFIX}message_queue_urgent} directive |
---|
449 | which posts a message to the queue on which the blocked task is |
---|
450 | waiting. |
---|
451 | |
---|
452 | @item A running task issues an @code{@value{DIRPREFIX}event_send} |
---|
453 | directive which sends an event condition to a task which is blocked |
---|
454 | waiting on that event condition. |
---|
455 | |
---|
456 | @item A running task issues a @code{@value{DIRPREFIX}semaphore_release} |
---|
457 | directive which releases the semaphore on which the blocked task is |
---|
458 | waiting. |
---|
459 | |
---|
460 | @item A timeout interval expires for a task which was blocked |
---|
461 | by a call to the @code{@value{DIRPREFIX}task_wake_after} directive. |
---|
462 | |
---|
463 | @item A timeout period expires for a task which blocked by a |
---|
464 | call to the @code{@value{DIRPREFIX}task_wake_when} directive. |
---|
465 | |
---|
466 | @item A running task issues a @code{@value{DIRPREFIX}region_return_segment} |
---|
467 | directive which releases a segment to the region on which the blocked task |
---|
468 | is waiting and a resulting segment is large enough to satisfy |
---|
469 | the task's request. |
---|
470 | |
---|
471 | @item A rate monotonic period expires for a task which blocked |
---|
472 | by a call to the @code{@value{DIRPREFIX}rate_monotonic_period} directive. |
---|
473 | |
---|
474 | @item A timeout interval expires for a task which was blocked |
---|
475 | waiting on a message, event, semaphore, or segment with a |
---|
476 | timeout specified. |
---|
477 | |
---|
478 | @item A running task issues a directive which deletes a |
---|
479 | message queue, a semaphore, or a region on which the blocked |
---|
480 | task is waiting. |
---|
481 | |
---|
482 | @item A running task issues a @code{@value{DIRPREFIX}task_restart} |
---|
483 | directive for the blocked task. |
---|
484 | |
---|
485 | @item The running task, with its preemption mode enabled, may |
---|
486 | be made ready by issuing any of the directives that may unblock |
---|
487 | a task with a higher priority. This directive may be issued |
---|
488 | from the running task itself or from an ISR. |
---|
489 | |
---|
490 | A ready task occupies the executing state when it has |
---|
491 | control of the CPU. A task enters the executing state due to |
---|
492 | any of the following conditions: |
---|
493 | |
---|
494 | @item The task is the highest priority ready task in the |
---|
495 | system. |
---|
496 | |
---|
497 | @item The running task blocks and the task is next in the |
---|
498 | scheduling queue. The task may be of equal priority as in |
---|
499 | round-robin scheduling or the task may possess the highest |
---|
500 | priority of the remaining ready tasks. |
---|
501 | |
---|
502 | @item The running task may reenable its preemption mode and a |
---|
503 | task exists in the ready queue that has a higher priority than |
---|
504 | the running task. |
---|
505 | |
---|
506 | @item The running task lowers its own priority and another |
---|
507 | task is of higher priority as a result. |
---|
508 | |
---|
509 | @item The running task raises the priority of a task above its |
---|
510 | own and the running task is in preemption mode. |
---|
511 | |
---|
512 | @end itemize |
---|