source: rtems-docs/c-user/scheduling_concepts.rst @ 21fe48e

5
Last change on this file since 21fe48e was 955d366, checked in by Sebastian Huber <sebastian.huber@…>, on 10/20/18 at 17:30:42

c-user: Clarify scheduler configuration

  • Property mode set to 100644
File size: 30.5 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2008.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7.. index:: scheduling
8.. index:: task scheduling
9
10.. _SchedulingConcepts:
11
12Scheduling Concepts
13*******************
14
15Introduction
16============
17
18The concept of scheduling in real-time systems dictates the ability to provide
19immediate response to specific external events, particularly the necessity of
20scheduling tasks to run within a specified time limit after the occurrence of
21an event.  For example, software embedded in life-support systems used to
22monitor hospital patients must take instant action if a change in the patient's
23status is detected.
24
25The component of RTEMS responsible for providing this capability is
26appropriately called the scheduler.  The scheduler's sole purpose is to
27allocate the all important resource of processor time to the various tasks
28competing for attention.
29
30The directives provided by the scheduler manager are:
31
32- rtems_scheduler_ident_ - Get ID of a scheduler
33
34- rtems_scheduler_ident_by_processor_ - Get ID of a scheduler by processor
35
36- rtems_scheduler_ident_by_processor_set_ - Get ID of a scheduler by processor set
37
38- rtems_scheduler_get_processor_set_ - Get processor set of a scheduler
39
40- rtems_scheduler_add_processor_ - Add processor to a scheduler
41
42- rtems_scheduler_remove_processor_ - Remove processor from a scheduler
43
44.. index:: scheduling algorithms
45
46Scheduling Algorithms
47---------------------
48
49RTEMS provides a plugin framework which allows it to support multiple
50scheduling algorithms. RTEMS includes multiple scheduling algorithms and the
51user can select which of these they wish to use in their application at
52link-time.  In addition, the user can implement their own scheduling algorithm
53and configure RTEMS to use it.
54
55Supporting multiple scheduling algorithms gives the end user the option to
56select the algorithm which is most appropriate to their use case. Most
57real-time operating systems schedule tasks using a priority based algorithm,
58possibly with preemption control.  The classic RTEMS scheduling algorithm which
59was the only algorithm available in RTEMS 4.10 and earlier, is a fixed-priority
60scheduling algorithm.  This scheduling algoritm is suitable for uniprocessor
61(e.g. non-SMP) systems and is known as the *Deterministic Priority
62Scheduler*.  Unless the user configures another scheduling algorithm, RTEMS
63will use this on uniprocessor systems.
64
65.. index:: priority scheduling
66
67Priority Scheduling
68-------------------
69
70When using priority based scheduling, RTEMS allocates the processor using a
71priority-based, preemptive algorithm augmented to provide round-robin
72characteristics within individual priority groups.  The goal of this algorithm
73is to guarantee that the task which is executing on the processor at any point
74in time is the one with the highest priority among all tasks in the ready
75state.
76
77When a task is added to the ready chain, it is placed behind all other tasks of
78the same priority.  This rule provides a round-robin within priority group
79scheduling characteristic.  This means that in a group of equal priority tasks,
80tasks will execute in the order they become ready or FIFO order.  Even though
81there are ways to manipulate and adjust task priorities, the most important
82rule to remember is:
83
84.. note::
85
86  Priority based scheduling algorithms will always select the highest priority
87  task that is ready to run when allocating the processor to a task.
88
89Priority scheduling is the most commonly used scheduling algorithm.  It should
90be used by applications in which multiple tasks contend for CPU time or other
91resources and there is a need to ensure certain tasks are given priority over
92other tasks.
93
94There are a few common methods of accomplishing the mechanics of this
95algorithm.  These ways involve a list or chain of tasks in the ready state.
96
97- The least efficient method is to randomly place tasks in the ready chain
98  forcing the scheduler to scan the entire chain to determine which task
99  receives the processor.
100
101- A more efficient method is to schedule the task by placing it in the proper
102  place on the ready chain based on the designated scheduling criteria at the
103  time it enters the ready state.  Thus, when the processor is free, the first
104  task on the ready chain is allocated the processor.
105
106- Another mechanism is to maintain a list of FIFOs per priority.  When a task
107  is readied, it is placed on the rear of the FIFO for its priority.  This
108  method is often used with a bitmap to assist in locating which FIFOs have
109  ready tasks on them.  This data structure has :math:`O(1)` insert, extract
110  and find highest ready run-time complexities.
111
112- A red-black tree may be used for the ready queue with the priority as the
113  key.  This data structure has :math:`O(log(n))` insert, extract and find
114  highest ready run-time complexities while :math:`n` is the count of tasks in
115  the ready queue.
116
117RTEMS currently includes multiple priority based scheduling algorithms as well
118as other algorithms which incorporate deadline.  Each algorithm is discussed in
119the following sections.
120
121Uniprocessor Schedulers
122=======================
123
124All uniprocessor schedulers included in RTEMS are priority based.  The
125processor is allocated to the highest priority task allowed to run.
126
127.. _SchedulerPriority:
128
129Deterministic Priority Scheduler
130--------------------------------
131
132This is the scheduler implementation which has always been in RTEMS.  After the
1334.10 release series, it was factored into pluggable scheduler selection.  It
134schedules tasks using a priority based algorithm which takes into account
135preemption.  It is implemented using an array of FIFOs with a FIFO per
136priority.  It maintains a bitmap which is used to track which priorities have
137ready tasks.
138
139This algorithm is deterministic (e.g. predictable and fixed) in execution time.
140This comes at the cost of using slightly over three (3) kilobytes of RAM on a
141system configured to support 256 priority levels.
142
143This scheduler is only aware of a single core.
144
145.. _SchedulerPrioritySimple:
146
147Simple Priority Scheduler
148-------------------------
149
150This scheduler implementation has the same behaviour as the Deterministic
151Priority Scheduler but uses only one linked list to manage all ready tasks.
152When a task is readied, a linear search of that linked list is performed to
153determine where to insert the newly readied task.
154
155This algorithm uses much less RAM than the Deterministic Priority Scheduler but
156is *O(n)* where *n* is the number of ready tasks.  In a small system with a
157small number of tasks, this will not be a performance issue.  Reducing RAM
158consumption is often critical in small systems which are incapable of
159supporting a large number of tasks.
160
161This scheduler is only aware of a single core.
162
163.. index:: earliest deadline first scheduling
164
165.. _SchedulerEDF:
166
167Earliest Deadline First Scheduler
168---------------------------------
169
170This is an alternative scheduler in RTEMS for single core applications.  The
171primary EDF advantage is high total CPU utilization (theoretically up to
172100%). It assumes that tasks have priorities equal to deadlines.
173
174This EDF is initially preemptive, however, individual tasks may be declared
175not-preemptive. Deadlines are declared using only Rate Monotonic manager which
176goal is to handle periodic behavior. Period is always equal to deadline. All
177ready tasks reside in a single ready queue implemented using a red-black tree.
178
179This implementation of EDF schedules two different types of task priority types
180while each task may switch between the two types within its execution. If a
181task does have a deadline declared using the Rate Monotonic manager, the task
182is deadline-driven and its priority is equal to deadline.  On the contrary if a
183task does not have any deadline or the deadline is cancelled using the Rate
184Monotonic manager, the task is considered a background task with priority equal
185to that assigned upon initialization in the same manner as for priority
186scheduler. Each background task is of a lower importance than each
187deadline-driven one and is scheduled when no deadline-driven task and no higher
188priority background task is ready to run.
189
190Every deadline-driven scheduling algorithm requires means for tasks to claim a
191deadline.  The Rate Monotonic Manager is responsible for handling periodic
192execution. In RTEMS periods are equal to deadlines, thus if a task announces a
193period, it has to be finished until the end of this period. The call of
194``rtems_rate_monotonic_period`` passes the scheduler the length of oncoming
195deadline. Moreover, the ``rtems_rate_monotonic_cancel`` and
196``rtems_rate_monotonic_delete`` calls clear the deadlines assigned to the task.
197
198.. index:: constant bandwidth server scheduling
199
200.. _SchedulerCBS:
201
202Constant Bandwidth Server Scheduling (CBS)
203------------------------------------------
204
205This is an alternative scheduler in RTEMS for single core applications.  The
206CBS is a budget aware extension of EDF scheduler. The main goal of this
207scheduler is to ensure temporal isolation of tasks meaning that a task's
208execution in terms of meeting deadlines must not be influenced by other tasks
209as if they were run on multiple independent processors.
210
211Each task can be assigned a server (current implementation supports only one
212task per server). The server is characterized by period (deadline) and
213computation time (budget). The ratio budget/period yields bandwidth, which is
214the fraction of CPU to be reserved by the scheduler for each subsequent period.
215
216The CBS is equipped with a set of rules applied to tasks attached to servers
217ensuring that deadline miss because of another task cannot occur.  In case a
218task breaks one of the rules, its priority is pulled to background until the
219end of its period and then restored again. The rules are:
220
221- Task cannot exceed its registered budget,
222
223- Task cannot be unblocked when a ratio between remaining budget and remaining
224  deadline is higher than declared bandwidth.
225
226The CBS provides an extensive API. Unlike EDF, the
227``rtems_rate_monotonic_period`` does not declare a deadline because it is
228carried out using CBS API. This call only announces next period.
229
230SMP Schedulers
231==============
232
233All SMP schedulers included in RTEMS are priority based.  The processors
234managed by a scheduler instance are allocated to the highest priority tasks
235allowed to run.
236
237.. _SchedulerSMPEDF:
238
239Earliest Deadline First SMP Scheduler
240-------------------------------------
241
242This is a job-level fixed-priority scheduler using the Earliest Deadline First
243(EDF) method.  By convention, the maximum priority level is
244:math:`min(INT\_MAX, 2^{62} - 1)` for background tasks.  Tasks without an
245active deadline are background tasks.  In case deadlines are not used, then the
246EDF scheduler behaves exactly like a fixed-priority scheduler.  The tasks with
247an active deadline have a higher priority than the background tasks.  This
248scheduler supports :ref:`task processor affinities <rtems_task_set_affinity>`
249of one-to-one and one-to-all, e.g.  a task can execute on exactly one processor
250or all processors managed by the scheduler instance.  The processor affinity
251set of a task must contain all online processors to select the one-to-all
252affinity.  This is to avoid pathological cases if processors are added/removed
253to/from the scheduler instance at run-time.  In case the processor affinity set
254contains not all online processors, then a one-to-one affinity will be used
255selecting the processor with the largest index within the set of processors
256currently owned by the scheduler instance.  This scheduler algorithm supports
257:ref:`thread pinning <ThreadPinning>`.  The ready queues use a red-black tree
258with the task priority as the key.
259
260This scheduler algorithm is the default scheduler in SMP configurations if more
261than one processor is configured (:ref:`CONFIGURE_MAXIMUM_PROCESSORS
262<CONFIGURE_MAXIMUM_PROCESSORS>`).
263
264.. _SchedulerSMPPriority:
265
266Deterministic Priority SMP Scheduler
267------------------------------------
268
269A fixed-priority scheduler which uses a table of chains with one chain per
270priority level for the ready tasks.  The maximum priority level is
271configurable.  By default, the maximum priority level is 255 (256 priority
272levels).
273
274.. _SchedulerSMPPrioritySimple:
275
276Simple Priority SMP Scheduler
277-----------------------------
278
279A fixed-priority scheduler which uses a sorted chain for the ready tasks.  By
280convention, the maximum priority level is 255.  The implementation limit is
281actually :math:`2^{63} - 1`.
282
283.. _SchedulerSMPPriorityAffinity:
284
285Arbitrary Processor Affinity Priority SMP Scheduler
286---------------------------------------------------
287
288A fixed-priority scheduler which uses a table of chains with one chain per
289priority level for the ready tasks.  The maximum priority level is
290configurable.  By default, the maximum priority level is 255 (256 priority
291levels).  This scheduler supports arbitrary task processor affinities.  The
292worst-case run-time complexity of some scheduler operations exceeds
293:math:`O(n)` while :math:`n` is the count of ready tasks.
294
295.. index:: scheduling mechanisms
296
297Scheduling Modification Mechanisms
298==================================
299
300RTEMS provides four mechanisms which allow the user to alter the task
301scheduling decisions:
302
303- user-selectable task priority level
304
305- task preemption control
306
307- task timeslicing control
308
309- manual round-robin selection
310
311Each of these methods provides a powerful capability to customize sets of tasks
312to satisfy the unique and particular requirements encountered in custom
313real-time applications.  Although each mechanism operates independently, there
314is a precedence relationship which governs the effects of scheduling
315modifications.  The evaluation order for scheduling characteristics is always
316priority, preemption mode, and timeslicing.  When reading the descriptions of
317timeslicing and manual round-robin it is important to keep in mind that
318preemption (if enabled) of a task by higher priority tasks will occur as
319required, overriding the other factors presented in the description.
320
321.. index:: task priority
322
323Task Priority and Scheduling
324----------------------------
325
326The most significant task scheduling modification mechanism is the ability for
327the user to assign a priority level to each individual task when it is created
328and to alter a task's priority at run-time.  The maximum priority level depends
329on the configured scheduler.  A lower priority level means higher priority
330(higher importance).  The maximum priority level of the default uniprocessor
331scheduler is 255.
332
333.. index:: preemption
334
335Preemption
336----------
337
338Another way the user can alter the basic scheduling algorithm is by
339manipulating the preemption mode flag (``RTEMS_PREEMPT_MASK``) of individual
340tasks.  If preemption is disabled for a task (``RTEMS_NO_PREEMPT``), then the
341task will not relinquish control of the processor until it terminates, blocks,
342or re-enables preemption.  Even tasks which become ready to run and possess
343higher priority levels will not be allowed to execute.  Note that the
344preemption setting has no effect on the manner in which a task is scheduled.
345It only applies once a task has control of the processor.
346
347.. index:: timeslicing
348.. index:: round robin scheduling
349
350Timeslicing
351-----------
352
353Timeslicing or round-robin scheduling is an additional method which can be used
354to alter the basic scheduling algorithm.  Like preemption, timeslicing is
355specified on a task by task basis using the timeslicing mode flag
356(``RTEMS_TIMESLICE_MASK``).  If timeslicing is enabled for a task
357(``RTEMS_TIMESLICE``), then RTEMS will limit the amount of time the task can
358execute before the processor is allocated to another task.  Each tick of the
359real-time clock reduces the currently running task's timeslice.  When the
360execution time equals the timeslice, RTEMS will dispatch another task of the
361same priority to execute.  If there are no other tasks of the same priority
362ready to execute, then the current task is allocated an additional timeslice
363and continues to run.  Remember that a higher priority task will preempt the
364task (unless preemption is disabled) as soon as it is ready to run, even if the
365task has not used up its entire timeslice.
366
367.. index:: manual round robin
368
369Manual Round-Robin
370------------------
371
372The final mechanism for altering the RTEMS scheduling algorithm is called
373manual round-robin.  Manual round-robin is invoked by using
374the ``rtems_task_wake_after`` directive with a time interval of
375``RTEMS_YIELD_PROCESSOR``.  This allows a task to give up the processor and be
376immediately returned to the ready chain at the end of its priority group.  If
377no other tasks of the same priority are ready to run, then the task does not
378lose control of the processor.
379
380.. index:: dispatching
381
382Dispatching Tasks
383=================
384
385The dispatcher is the RTEMS component responsible for allocating the processor
386to a ready task.  In order to allocate the processor to one task, it must be
387deallocated or retrieved from the task currently using it.  This involves a
388concept called a context switch.  To perform a context switch, the dispatcher
389saves the context of the current task and restores the context of the task
390which has been allocated to the processor.  Saving and restoring a task's
391context is the storing/loading of all the essential information about a task to
392enable it to continue execution without any effects of the interruption.  For
393example, the contents of a task's register set must be the same when it is
394given the processor as they were when it was taken away.  All of the
395information that must be saved or restored for a context switch is located
396either in the TCB or on the task's stacks.
397
398Tasks that utilize a numeric coprocessor and are created with the
399``RTEMS_FLOATING_POINT`` attribute require additional operations during a
400context switch.  These additional operations are necessary to save and restore
401the floating point context of ``RTEMS_FLOATING_POINT`` tasks.  To avoid
402unnecessary save and restore operations, the state of the numeric coprocessor
403is only saved when a ``RTEMS_FLOATING_POINT`` task is dispatched and that task
404was not the last task to utilize the coprocessor.
405
406.. index:: task state transitions
407
408Task State Transitions
409======================
410
411Tasks in an RTEMS system must always be in one of the five allowable task
412states.  These states are: executing, ready, blocked, dormant, and
413non-existent.
414
415A task occupies the non-existent state before a ``rtems_task_create`` has been
416issued on its behalf.  A task enters the non-existent state from any other
417state in the system when it is deleted with the ``rtems_task_delete``
418directive.  While a task occupies this state it does not have a TCB or a task
419ID assigned to it; therefore, no other tasks in the system may reference this
420task.
421
422When a task is created via the ``rtems_task_create`` directive it enters the
423dormant state.  This state is not entered through any other means.  Although
424the task exists in the system, it cannot actively compete for system resources.
425It will remain in the dormant state until it is started via the
426``rtems_task_start`` directive, at which time it enters the ready state.  The
427task is now permitted to be scheduled for the processor and to compete for
428other system resources.
429
430.. figure:: ../images/c_user/states.png
431         :width: 70%
432         :align: center
433         :alt: Task State Transitions
434
435A task occupies the blocked state whenever it is unable to be scheduled to run.
436A running task may block itself or be blocked by other tasks in the system.
437The running task blocks itself through voluntary operations that cause the task
438to wait.  The only way a task can block a task other than itself is with the
439``rtems_task_suspend`` directive.  A task enters the blocked state due to any
440of the following conditions:
441
442- A task issues a ``rtems_task_suspend`` directive which blocks either itself
443  or another task in the system.
444
445- The running task issues a ``rtems_barrier_wait`` directive.
446
447- The running task issues a ``rtems_message_queue_receive`` directive with the
448  wait option and the message queue is empty.
449
450- The running task issues an ``rtems_event_receive`` directive with the wait
451  option and the currently pending events do not satisfy the request.
452
453- The running task issues a ``rtems_semaphore_obtain`` directive with the wait
454  option and the requested semaphore is unavailable.
455
456- The running task issues a ``rtems_task_wake_after`` directive which blocks
457  the task for the given time interval.  If the time interval specified is
458  zero, the task yields the processor and remains in the ready state.
459
460- The running task issues a ``rtems_task_wake_when`` directive which blocks the
461  task until the requested date and time arrives.
462
463- The running task issues a ``rtems_rate_monotonic_period`` directive and must
464  wait for the specified rate monotonic period to conclude.
465
466- The running task issues a ``rtems_region_get_segment`` directive with the
467  wait option and there is not an available segment large enough to satisfy the
468  task's request.
469
470A blocked task may also be suspended.  Therefore, both the suspension and the
471blocking condition must be removed before the task becomes ready to run again.
472
473A task occupies the ready state when it is able to be scheduled to run, but
474currently does not have control of the processor.  Tasks of the same or higher
475priority will yield the processor by either becoming blocked, completing their
476timeslice, or being deleted.  All tasks with the same priority will execute in
477FIFO order.  A task enters the ready state due to any of the following
478conditions:
479
480- A running task issues a ``rtems_task_resume`` directive for a task that is
481  suspended and the task is not blocked waiting on any resource.
482
483- A running task issues a ``rtems_message_queue_send``,
484  ``rtems_message_queue_broadcast``, or a ``rtems_message_queue_urgent``
485  directive which posts a message to the queue on which the blocked task is
486  waiting.
487
488- A running task issues an ``rtems_event_send`` directive which sends an event
489  condition to a task which is blocked waiting on that event condition.
490
491- A running task issues a ``rtems_semaphore_release`` directive which releases
492  the semaphore on which the blocked task is waiting.
493
494- A timeout interval expires for a task which was blocked by a call to the
495  ``rtems_task_wake_after`` directive.
496
497- A timeout period expires for a task which blocked by a call to the
498  ``rtems_task_wake_when`` directive.
499
500- A running task issues a ``rtems_region_return_segment`` directive which
501  releases a segment to the region on which the blocked task is waiting and a
502  resulting segment is large enough to satisfy the task's request.
503
504- A rate monotonic period expires for a task which blocked by a call to the
505  ``rtems_rate_monotonic_period`` directive.
506
507- A timeout interval expires for a task which was blocked waiting on a message,
508  event, semaphore, or segment with a timeout specified.
509
510- A running task issues a directive which deletes a message queue, a semaphore,
511  or a region on which the blocked task is waiting.
512
513- A running task issues a ``rtems_task_restart`` directive for the blocked
514  task.
515
516- The running task, with its preemption mode enabled, may be made ready by
517  issuing any of the directives that may unblock a task with a higher priority.
518  This directive may be issued from the running task itself or from an ISR.  A
519  ready task occupies the executing state when it has control of the CPU.  A
520  task enters the executing state due to any of the following conditions:
521
522- The task is the highest priority ready task in the system.
523
524- The running task blocks and the task is next in the scheduling queue.  The
525  task may be of equal priority as in round-robin scheduling or the task may
526  possess the highest priority of the remaining ready tasks.
527
528- The running task may reenable its preemption mode and a task exists in the
529  ready queue that has a higher priority than the running task.
530
531- The running task lowers its own priority and another task is of higher
532  priority as a result.
533
534- The running task raises the priority of a task above its own and the running
535  task is in preemption mode.
536
537Directives
538==========
539
540This section details the scheduler manager.  A subsection is dedicated to each
541of these services and describes the calling sequence, related constants, usage,
542and status codes.
543
544.. raw:: latex
545
546   \clearpage
547
548.. _rtems_scheduler_ident:
549
550SCHEDULER_IDENT - Get ID of a scheduler
551---------------------------------------
552
553CALLING SEQUENCE:
554    .. code-block:: c
555
556        rtems_status_code rtems_scheduler_ident(
557            rtems_name  name,
558            rtems_id   *id
559        );
560
561DIRECTIVE STATUS CODES:
562    .. list-table::
563     :class: rtems-table
564
565     * - ``RTEMS_SUCCESSFUL``
566       - Successful operation.
567     * - ``RTEMS_INVALID_ADDRESS``
568       - The ``id`` parameter is ``NULL``.
569     * - ``RTEMS_INVALID_NAME``
570       - Invalid scheduler name.
571
572DESCRIPTION:
573    Identifies a scheduler by its name.  The scheduler name is determined by
574    the scheduler configuration.  See :ref:`ConfigurationSchedulerTable`
575    and :ref:`CONFIGURE_SCHEDULER_NAME`.
576
577NOTES:
578    None.
579
580.. raw:: latex
581
582   \clearpage
583
584.. _rtems_scheduler_ident_by_processor:
585
586SCHEDULER_IDENT_BY_PROCESSOR - Get ID of a scheduler by processor
587-----------------------------------------------------------------
588
589CALLING SEQUENCE:
590    .. code-block:: c
591
592        rtems_status_code rtems_scheduler_ident_by_processor(
593            uint32_t  cpu_index,
594            rtems_id *id
595        );
596
597DIRECTIVE STATUS CODES:
598    .. list-table::
599     :class: rtems-table
600
601     * - ``RTEMS_SUCCESSFUL``
602       - Successful operation.
603     * - ``RTEMS_INVALID_ADDRESS``
604       - The ``id`` parameter is ``NULL``.
605     * - ``RTEMS_INVALID_NAME``
606       - Invalid processor index.
607     * - ``RTEMS_INCORRECT_STATE``
608       - The processor index is valid, however, this processor is not owned by
609         a scheduler.
610
611DESCRIPTION:
612    Identifies a scheduler by a processor.
613
614NOTES:
615    None.
616
617.. raw:: latex
618
619   \clearpage
620
621.. _rtems_scheduler_ident_by_processor_set:
622
623SCHEDULER_IDENT_BY_PROCESSOR_SET - Get ID of a scheduler by processor set
624-------------------------------------------------------------------------
625
626CALLING SEQUENCE:
627    .. code-block:: c
628
629        rtems_status_code rtems_scheduler_ident_by_processor_set(
630            size_t           cpusetsize,
631            const cpu_set_t *cpuset,
632            rtems_id        *id
633        );
634
635DIRECTIVE STATUS CODES:
636    .. list-table::
637     :class: rtems-table
638
639     * - ``RTEMS_SUCCESSFUL``
640       - Successful operation.
641     * - ``RTEMS_INVALID_ADDRESS``
642       - The ``id`` parameter is ``NULL``.
643     * - ``RTEMS_INVALID_SIZE``
644       - Invalid processor set size.
645     * - ``RTEMS_INVALID_NAME``
646       - The processor set contains no online processor.
647     * - ``RTEMS_INCORRECT_STATE``
648       - The processor set is valid, however, the highest numbered online
649         processor in the specified processor set is not owned by a scheduler.
650
651DESCRIPTION:
652    Identifies a scheduler by a processor set.  The scheduler is selected
653    according to the highest numbered online processor in the specified
654    processor set.
655
656NOTES:
657    None.
658
659.. raw:: latex
660
661   \clearpage
662
663.. _rtems_scheduler_get_processor_set:
664
665SCHEDULER_GET_PROCESSOR_SET - Get processor set of a scheduler
666--------------------------------------------------------------
667
668CALLING SEQUENCE:
669    .. code-block:: c
670
671        rtems_status_code rtems_scheduler_get_processor_set(
672            rtems_id   scheduler_id,
673            size_t     cpusetsize,
674            cpu_set_t *cpuset
675        );
676
677DIRECTIVE STATUS CODES:
678    .. list-table::
679     :class: rtems-table
680
681     * - ``RTEMS_SUCCESSFUL``
682       - Successful operation.
683     * - ``RTEMS_INVALID_ID``
684       - Invalid scheduler instance identifier.
685     * - ``RTEMS_INVALID_ADDRESS``
686       - The ``cpuset`` parameter is ``NULL``.
687     * - ``RTEMS_INVALID_NUMBER``
688       - The processor set buffer is too small for the set of processors owned
689         by the scheduler instance.
690
691DESCRIPTION:
692    Returns the processor set owned by the scheduler instance in ``cpuset``.  A
693    set bit in the processor set means that this processor is owned by the
694    scheduler instance and a cleared bit means the opposite.
695
696NOTES:
697    None.
698
699.. raw:: latex
700
701   \clearpage
702
703.. _rtems_scheduler_add_processor:
704
705SCHEDULER_ADD_PROCESSOR - Add processor to a scheduler
706------------------------------------------------------
707
708CALLING SEQUENCE:
709    .. code-block:: c
710
711        rtems_status_code rtems_scheduler_add_processor(
712            rtems_id scheduler_id,
713            uint32_t cpu_index
714        );
715
716DIRECTIVE STATUS CODES:
717    .. list-table::
718     :class: rtems-table
719
720     * - ``RTEMS_SUCCESSFUL``
721       - Successful operation.
722     * - ``RTEMS_INVALID_ID``
723       - Invalid scheduler instance identifier.
724     * - ``RTEMS_NOT_CONFIGURED``
725       - The processor is not configured to be used by the application.
726     * - ``RTEMS_INCORRECT_STATE``
727       - The processor is configured to be used by the application, however, it
728         is not online.
729     * - ``RTEMS_RESOURCE_IN_USE``
730       - The processor is already assigned to a scheduler instance.
731
732DESCRIPTION:
733    Adds a processor to the set of processors owned by the specified scheduler
734    instance.
735
736NOTES:
737    Must be called from task context.  This operation obtains and releases the
738    objects allocator lock.
739
740.. raw:: latex
741
742   \clearpage
743
744.. _rtems_scheduler_remove_processor:
745
746SCHEDULER_REMOVE_PROCESSOR - Remove processor from a scheduler
747--------------------------------------------------------------
748
749CALLING SEQUENCE:
750    .. code-block:: c
751
752        rtems_status_code rtems_scheduler_remove_processor(
753            rtems_id scheduler_id,
754            uint32_t cpu_index
755        );
756
757DIRECTIVE STATUS CODES:
758    .. list-table::
759     :class: rtems-table
760
761     * - ``RTEMS_SUCCESSFUL``
762       - Successful operation.
763     * - ``RTEMS_INVALID_ID``
764       - Invalid scheduler instance identifier.
765     * - ``RTEMS_INVALID_NUMBER``
766       - The processor is not owned by the specified scheduler instance.
767     * - ``RTEMS_RESOURCE_IN_USE``
768       - The set of processors owned by the specified scheduler instance would
769         be empty after the processor removal and there exists a non-idle task
770         that uses this scheduler instance as its home scheduler instance.
771     * - ``RTEMS_RESOURCE_IN_USE``
772       - A task with a restricted processor affinity exists that uses this
773         scheduler instance as its home scheduler instance and it would be no
774         longer possible to allocate a processor for this task after the
775         removal of this processor.
776
777DESCRIPTION:
778    Removes a processor from set of processors owned by the specified scheduler
779    instance.
780
781NOTES:
782    Must be called from task context.  This operation obtains and releases the
783    objects allocator lock.  Removing a processor from a scheduler is a complex
784    operation that involves all tasks of the system.
Note: See TracBrowser for help on using the repository browser.