summaryrefslogtreecommitdiffstats
path: root/c-user/scheduling-concepts/directives.rst
blob: 5b1246f42eeac7466aaabb268563ed4c3ad36060 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
.. SPDX-License-Identifier: CC-BY-SA-4.0

.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)

Directives
==========

This section details the scheduler manager.  A subsection is dedicated to each
of these services and describes the calling sequence, related constants, usage,
and status codes.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_ident:

SCHEDULER_IDENT - Get ID of a scheduler
---------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_ident(
            rtems_name  name,
            rtems_id   *id
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``id`` parameter is ``NULL``.
     * - ``RTEMS_INVALID_NAME``
       - Invalid scheduler name.

DESCRIPTION:
    Identifies a scheduler by its name.  The scheduler name is determined by
    the scheduler configuration.  See :ref:`ConfigurationSchedulerTable`
    and :ref:`CONFIGURE_SCHEDULER_NAME`.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_ident_by_processor:

SCHEDULER_IDENT_BY_PROCESSOR - Get ID of a scheduler by processor
-----------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_ident_by_processor(
            uint32_t  cpu_index,
            rtems_id *id
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``id`` parameter is ``NULL``.
     * - ``RTEMS_INVALID_NAME``
       - Invalid processor index.
     * - ``RTEMS_INCORRECT_STATE``
       - The processor index is valid, however, this processor is not owned by
         a scheduler.

DESCRIPTION:
    Identifies a scheduler by a processor.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_ident_by_processor_set:

SCHEDULER_IDENT_BY_PROCESSOR_SET - Get ID of a scheduler by processor set
-------------------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_ident_by_processor_set(
            size_t           cpusetsize,
            const cpu_set_t *cpuset,
            rtems_id        *id
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``id`` parameter is ``NULL``.
     * - ``RTEMS_INVALID_SIZE``
       - Invalid processor set size.
     * - ``RTEMS_INVALID_NAME``
       - The processor set contains no online processor.
     * - ``RTEMS_INCORRECT_STATE``
       - The processor set is valid, however, the highest numbered online
         processor in the specified processor set is not owned by a scheduler.

DESCRIPTION:
    Identifies a scheduler by a processor set.  The scheduler is selected
    according to the highest numbered online processor in the specified
    processor set.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_get_maximum_priority:

SCHEDULER_GET_MAXIMUM_PRIORITY - Get maximum task priority of a scheduler
-------------------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_get_maximum_priority(
            rtems_id             scheduler_id,
            rtems_task_priority *priority
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ID``
       - Invalid scheduler instance identifier.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``priority`` parameter is ``NULL``.

DESCRIPTION:
    Returns the maximum task priority of the specified scheduler instance in
    ``priority``.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_map_priority_to_posix:

SCHEDULER_MAP_PRIORITY_TO_POSIX - Map task priority to POSIX thread prority
---------------------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_map_priority_to_posix(
            rtems_id             scheduler_id,
            rtems_task_priority  priority,
            int                 *posix_priority
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``posix_priority`` parameter is ``NULL``.
     * - ``RTEMS_INVALID_ID``
       - Invalid scheduler instance identifier.
     * - ``RTEMS_INVALID_PRIORITY``
       - Invalid task priority.

DESCRIPTION:
    Maps a task priority to the corresponding POSIX thread priority.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_map_priority_from_posix:

SCHEDULER_MAP_PRIORITY_FROM_POSIX - Map POSIX thread prority to task priority
-----------------------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_map_priority_from_posix(
            rtems_id             scheduler_id,
            int                  posix_priority,
            rtems_task_priority *priority
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``priority`` parameter is ``NULL``.
     * - ``RTEMS_INVALID_ID``
       - Invalid scheduler instance identifier.
     * - ``RTEMS_INVALID_PRIORITY``
       - Invalid POSIX thread priority.

DESCRIPTION:
    Maps a POSIX thread priority to the corresponding task priority.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_get_processor:

SCHEDULER_GET_PROCESSOR - Get current processor index
-----------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        uint32_t rtems_scheduler_get_processor( void );

DIRECTIVE STATUS CODES:
    This directive returns the index of the current processor.

DESCRIPTION:
    In uniprocessor configurations, a value of zero will be returned.

    In SMP configurations, an architecture specific method is used to obtain the
    index of the current processor in the system.  The set of processor indices
    is the range of integers starting with zero up to the processor count minus
    one.

    Outside of sections with disabled thread dispatching the current processor
    index may change after every instruction since the thread may migrate from
    one processor to another.  Sections with disabled interrupts are sections
    with thread dispatching disabled.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_get_processor_maximum:

SCHEDULER_GET_PROCESSOR_MAXIMUM - Get processor maximum
-------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        uint32_t rtems_scheduler_get_processor_maximum( void );

DIRECTIVE STATUS CODES:
    This directive returns the processor maximum supported by the system.

DESCRIPTION:
    In uniprocessor configurations, a value of one will be returned.

    In SMP configurations, this directive returns the minimum of the processors
    (physically or virtually) available by the platform and the configured
    processor maximum.  Not all processors in the range from processor index
    zero to the last processor index (which is the processor maximum minus one)
    may be configured to be used by a scheduler or online (online processors
    have a scheduler assigned).

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_get_processor_set:

SCHEDULER_GET_PROCESSOR_SET - Get processor set of a scheduler
--------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_get_processor_set(
            rtems_id   scheduler_id,
            size_t     cpusetsize,
            cpu_set_t *cpuset
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ID``
       - Invalid scheduler instance identifier.
     * - ``RTEMS_INVALID_ADDRESS``
       - The ``cpuset`` parameter is ``NULL``.
     * - ``RTEMS_INVALID_NUMBER``
       - The processor set buffer is too small for the set of processors owned
         by the scheduler instance.

DESCRIPTION:
    Returns the processor set owned by the scheduler instance in ``cpuset``.  A
    set bit in the processor set means that this processor is owned by the
    scheduler instance and a cleared bit means the opposite.

NOTES:
    None.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_add_processor:

SCHEDULER_ADD_PROCESSOR - Add processor to a scheduler
------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_add_processor(
            rtems_id scheduler_id,
            uint32_t cpu_index
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ID``
       - Invalid scheduler instance identifier.
     * - ``RTEMS_NOT_CONFIGURED``
       - The processor is not configured to be used by the application.
     * - ``RTEMS_INCORRECT_STATE``
       - The processor is configured to be used by the application, however, it
         is not online.
     * - ``RTEMS_RESOURCE_IN_USE``
       - The processor is already assigned to a scheduler instance.

DESCRIPTION:
    Adds a processor to the set of processors owned by the specified scheduler
    instance.

NOTES:
    Must be called from task context.  This operation obtains and releases the
    objects allocator lock.

.. raw:: latex

   \clearpage

.. _rtems_scheduler_remove_processor:

SCHEDULER_REMOVE_PROCESSOR - Remove processor from a scheduler
--------------------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_scheduler_remove_processor(
            rtems_id scheduler_id,
            uint32_t cpu_index
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - Successful operation.
     * - ``RTEMS_INVALID_ID``
       - Invalid scheduler instance identifier.
     * - ``RTEMS_INVALID_NUMBER``
       - The processor is not owned by the specified scheduler instance.
     * - ``RTEMS_RESOURCE_IN_USE``
       - The set of processors owned by the specified scheduler instance would
         be empty after the processor removal and there exists a non-idle task
         that uses this scheduler instance as its home scheduler instance.
     * - ``RTEMS_RESOURCE_IN_USE``
       - A task with a restricted processor affinity exists that uses this
         scheduler instance as its home scheduler instance and it would be no
         longer possible to allocate a processor for this task after the
         removal of this processor.

DESCRIPTION:
    Removes a processor from set of processors owned by the specified scheduler
    instance.

NOTES:
    Must be called from task context.  This operation obtains and releases the
    objects allocator lock.  Removing a processor from a scheduler is a complex
    operation that involves all tasks of the system.