source: rtems-docs/c-user/scheduling_concepts.rst @ 42d50d7

5
Last change on this file since 42d50d7 was a31dbcb, checked in by Sebastian Huber <sebastian.huber@…>, on 07/12/17 at 06:28:06

c-user: Document new scheduler ident routines

Close #3069.
Close #3070.

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