source: rtems/cpukit/include/rtems/rtems/tasks.h @ 51f7a82

Last change on this file since 51f7a82 was 51f7a82, checked in by Sebastian Huber <sebastian.huber@…>, on 05/12/21 at 12:13:13

rtems: Clarify rtems_task_get_priority() doc

  • Property mode set to 100644
File size: 80.8 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief This header file defines the main parts of the Tasks Manager API.
7 */
8
9/*
10 * Copyright (C) 2013, 2021 embedded brains GmbH (http://www.embedded-brains.de)
11 * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR)
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * This file is part of the RTEMS quality process and was automatically
37 * generated.  If you find something that needs to be fixed or
38 * worded better please post a report or patch to an RTEMS mailing list
39 * or raise a bug report:
40 *
41 * https://www.rtems.org/bugs.html
42 *
43 * For information on updating and regenerating please refer to the How-To
44 * section in the Software Requirements Engineering chapter of the
45 * RTEMS Software Engineering manual.  The manual is provided as a part of
46 * a release.  For development sources please refer to the online
47 * documentation at:
48 *
49 * https://docs.rtems.org
50 */
51
52/* Generated from spec:/rtems/task/if/header */
53
54#ifndef _RTEMS_RTEMS_TASKS_H
55#define _RTEMS_RTEMS_TASKS_H
56
57#include <stdbool.h>
58#include <stddef.h>
59#include <stdint.h>
60#include <sys/cpuset.h>
61#include <rtems/rtems/attr.h>
62#include <rtems/rtems/modes.h>
63#include <rtems/rtems/status.h>
64#include <rtems/rtems/types.h>
65#include <rtems/score/basedefs.h>
66#include <rtems/score/context.h>
67#include <rtems/score/cpu.h>
68#include <rtems/score/object.h>
69#include <rtems/score/smp.h>
70#include <rtems/score/stack.h>
71#include <rtems/score/watchdogticks.h>
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77/* Generated from spec:/rtems/scheduler/if/group */
78
79/**
80 * @defgroup RTEMSAPIClassicScheduler Scheduler Manager
81 *
82 * @ingroup RTEMSAPIClassic
83 *
84 * @brief The scheduling concepts relate to the allocation of processing time
85 *   for tasks.
86 *
87 * The concept of scheduling in real-time systems dictates the ability to
88 * provide an immediate response to specific external events, particularly the
89 * necessity of scheduling tasks to run within a specified time limit after the
90 * occurrence of an event. For example, software embedded in life-support
91 * systems used to monitor hospital patients must take instant action if a
92 * change in the patient’s status is detected.
93 *
94 * The component of RTEMS responsible for providing this capability is
95 * appropriately called the scheduler. The scheduler’s sole purpose is to
96 * allocate the all important resource of processor time to the various tasks
97 * competing for attention.
98 */
99
100/* Generated from spec:/rtems/task/if/group */
101
102/**
103 * @defgroup RTEMSAPIClassicTasks Task Manager
104 *
105 * @ingroup RTEMSAPIClassic
106 *
107 * @brief The Task Manager provides a comprehensive set of directives to
108 *   create, delete, and administer tasks.
109 */
110
111/* Generated from spec:/rtems/task/if/argument */
112
113/**
114 * @ingroup RTEMSAPIClassicTasks
115 *
116 * @brief This integer type represents task argument values.
117 *
118 * @par Notes
119 * The type is an architecture-specific unsigned integer type which is large
120 * enough to represent pointer values and 32-bit unsigned integers.
121 */
122typedef CPU_Uint32ptr rtems_task_argument;
123
124/* Generated from spec:/rtems/task/if/config */
125
126/**
127 * @ingroup RTEMSAPIClassicTasks
128 *
129 * @brief This structure defines the configuration of a task constructed by
130 *   rtems_task_construct().
131 */
132typedef struct {
133  /**
134   * @brief This member defines the name of the task.
135   */
136  rtems_name name;
137
138  /**
139   * @brief This member defines the initial priority of the task.
140   */
141  rtems_task_priority initial_priority;
142
143  /**
144   * @brief This member shall point to the task storage area begin.
145   *
146   * The task storage area will contain the task stack, the thread-local storage,
147   * and the floating-point context on architectures with a separate
148   * floating-point context.
149   *
150   * The task storage area begin address and size should be aligned by
151   * #RTEMS_TASK_STORAGE_ALIGNMENT.  To avoid memory waste, use RTEMS_ALIGNED()
152   * and #RTEMS_TASK_STORAGE_ALIGNMENT to enforce the recommended alignment of a
153   * statically allocated task storage area.
154   */
155  void *storage_area;
156
157  /**
158   * @brief This member defines size of the task storage area in bytes.
159   *
160   * Use the RTEMS_TASK_STORAGE_SIZE() macro to determine the recommended task
161   * storage area size.
162   */
163  size_t storage_size;
164
165  /**
166   * @brief This member defines the maximum thread-local storage size supported
167   *   by the task storage area.
168   *
169   * Use RTEMS_ALIGN_UP() and #RTEMS_TASK_STORAGE_ALIGNMENT to adjust the size to
170   * meet the minimum alignment requirement of a thread-local storage area used
171   * to construct a task.
172   *
173   * If the value is less than the actual thread-local storage size, then the
174   * task construction by rtems_task_construct() fails.
175   *
176   * If the is less than the task storage area size, then the task construction
177   * by rtems_task_construct() fails.
178   *
179   * The actual thread-local storage size is determined when the application
180   * executable is linked.  The ``rtems-exeinfo`` command line tool included in
181   * the RTEMS Tools can be used to obtain the thread-local storage size and
182   * alignment of an application executable.
183   *
184   * The application may configure the maximum thread-local storage size for all
185   * threads explicitly through the #CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE
186   * configuration option.
187   */
188  size_t maximum_thread_local_storage_size;
189
190  /**
191   * @brief This member defines the optional handler to free the task storage
192   *   area.
193   *
194   * It is called on exactly two mutually exclusive occasions.  Firstly, when the
195   * task construction aborts due to a failed task create extension, or secondly,
196   * when the task is deleted.  It is called from task context under protection
197   * of the object allocator lock.  It is allowed to call free() in this handler.
198   * If handler is NULL, then no action will be performed.
199   */
200  void ( *storage_free )( void * );
201
202  /**
203   * @brief This member defines the initial modes of the task.
204   */
205  rtems_mode initial_modes;
206
207  /**
208   * @brief This member defines the attributes of the task.
209   */
210  rtems_attribute attributes;
211} rtems_task_config;
212
213/* Generated from spec:/rtems/task/if/configured-minimum-stack-size */
214
215/**
216 * @ingroup RTEMSAPIClassicTasks
217 *
218 * @brief This constant can be used to indicate that the task should be created
219 *   with the configured minimum stack size.
220 *
221 * Using this constant when specifying the task stack size indicates that this
222 * task is to be created with a stack size of the minimum stack size that was
223 * configured by the application. If not explicitly configured by the
224 * application, the default configured minimum stack size is
225 * #RTEMS_MINIMUM_STACK_SIZE which depends on the target architecture. Since
226 * this uses the configured minimum stack size value, you may get a stack size
227 * that is smaller or larger than the recommended minimum. This can be used to
228 * provide large stacks for all tasks on complex applications or small stacks
229 * on applications that are trying to conserve memory.
230 */
231#define RTEMS_CONFIGURED_MINIMUM_STACK_SIZE 0
232
233/* Generated from spec:/rtems/task/if/current-priority */
234
235/**
236 * @ingroup RTEMSAPIClassicTasks
237 *
238 * @brief This constant is passed to {set-priority:/name} when the caller wants
239 *   to obtain the current priority.
240 */
241#define RTEMS_CURRENT_PRIORITY 0
242
243/* Generated from spec:/rtems/task/if/task */
244
245/**
246 * @ingroup RTEMSAPIClassicTasks
247 *
248 * @brief This type defines the return type of task entry points.
249 *
250 * This type can be used to document task entry points in the source code.
251 */
252typedef void rtems_task;
253
254/* Generated from spec:/rtems/task/if/entry */
255
256/**
257 * @ingroup RTEMSAPIClassicTasks
258 *
259 * @brief This type defines the entry point of an RTEMS task.
260 */
261typedef rtems_task ( *rtems_task_entry )( rtems_task_argument );
262
263/* Generated from spec:/rtems/task/if/initialization-table */
264
265/**
266 * @ingroup RTEMSAPIClassicTasks
267 *
268 * @brief This structure defines the properties of the Classic API user
269 *   initialization task.
270 */
271typedef struct {
272  /**
273   * @brief This member defines the task name.
274   */
275  rtems_name name;
276
277  /**
278   * @brief This member defines the task stack size in bytes.
279   */
280  size_t stack_size;
281
282  /**
283   * @brief This member defines the initial task priority.
284   */
285  rtems_task_priority initial_priority;
286
287  /**
288   * @brief This member defines the attribute set of the task.
289   */
290  rtems_attribute attribute_set;
291
292  /**
293   * @brief This member defines the entry point of the task.
294   */
295  rtems_task_entry entry_point;
296
297  /**
298   * @brief This member defines the initial modes of the task.
299   */
300  rtems_mode mode_set;
301
302  /**
303   * @brief This member defines the entry point argument of the task.
304   */
305  rtems_task_argument argument;
306} rtems_initialization_tasks_table;
307
308/* Generated from spec:/rtems/task/if/minimum-priority */
309
310/**
311 * @ingroup RTEMSAPIClassicTasks
312 *
313 * @brief This compile time constant provides the highest (most important) task
314 *   priority settable by the API.
315 */
316#define RTEMS_MINIMUM_PRIORITY 1
317
318/* Generated from spec:/rtems/task/if/minimum-stack-size */
319
320/**
321 * @ingroup RTEMSAPIClassicTasks
322 *
323 * @brief This compile time constant provides the minimum task stack size
324 *   recommended for the target architecture.
325 *
326 * It is the minimum stack size recommended for use on this processor.  This
327 * value is selected by the RTEMS maintainers conservatively to minimize the
328 * risk of blown stacks for most user applications.  Using this constant when
329 * specifying the task stack size, indicates that the stack size will be at
330 * least RTEMS_MINIMUM_STACK_SIZE bytes in size.  If the user configured
331 * minimum stack size (see #CONFIGURE_MINIMUM_TASK_STACK_SIZE) is larger than
332 * the recommended minimum, then it will be used.
333 */
334#define RTEMS_MINIMUM_STACK_SIZE STACK_MINIMUM_SIZE
335
336/* Generated from spec:/rtems/task/if/no-priority */
337
338/**
339 * @ingroup RTEMSAPIClassicTasks
340 *
341 * @brief This compile time constant may be used for the
342 *   rtems_task_set_priority() directive to get the current task priority.
343 */
344#define RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY
345
346/* Generated from spec:/rtems/task/if/self-define */
347
348/**
349 * @ingroup RTEMSAPIClassicTasks
350 *
351 * @brief This compile time constant may be used to identify the calling task
352 *   in task related directives.
353 */
354#define RTEMS_SELF OBJECTS_ID_OF_SELF
355
356/* Generated from spec:/rtems/task/if/storage-alignment */
357
358/**
359 * @ingroup RTEMSAPIClassicTasks
360 *
361 * @brief This compile time constant defines the recommended alignment of a
362 *   task storage area in bytes.
363 *
364 * @par Notes
365 * Use it with RTEMS_ALIGNED() to define the alignment of a statically
366 * allocated task storage area.
367 */
368#define RTEMS_TASK_STORAGE_ALIGNMENT CPU_STACK_ALIGNMENT
369
370/* Generated from spec:/rtems/task/if/storage-size */
371
372/**
373 * @ingroup RTEMSAPIClassicTasks
374 *
375 * @brief Gets the recommended task storage area size for the size and task
376 *   attributes.
377 *
378 * @param _size is the size dedicated to the task stack and thread-local
379 *   storage in bytes.
380 *
381 * @param _attributes is the attribute set of the task using the storage area.
382 *
383 * @return Returns the recommended task storage area size calculated from the
384 *   input parameters.
385 */
386#if CPU_ALL_TASKS_ARE_FP == TRUE
387  #define RTEMS_TASK_STORAGE_SIZE( _size, _attributes ) \
388    ( ( _size ) + CONTEXT_FP_SIZE )
389#else
390  #define RTEMS_TASK_STORAGE_SIZE( _size, _attributes ) \
391    ( ( _size ) + \
392      ( ( ( _attributes ) & RTEMS_FLOATING_POINT ) != 0 ? \
393        CONTEXT_FP_SIZE : 0 ) )
394#endif
395
396/* Generated from spec:/rtems/task/if/tcb */
397
398/**
399 * @ingroup RTEMSAPIClassicTasks
400 *
401 * @brief This structure represents the TCB.
402 */
403typedef struct _Thread_Control rtems_tcb;
404
405/* Generated from spec:/rtems/task/if/visitor */
406
407/**
408 * @ingroup RTEMSAPIClassicTasks
409 *
410 * @brief Visitor routines invoked by rtems_task_iterate() shall have this
411 *   type.
412 */
413typedef bool( *rtems_task_visitor )( rtems_tcb *, void * );
414
415/* Generated from spec:/rtems/task/if/yield-processor */
416
417/**
418 * @ingroup RTEMSAPIClassicTasks
419 *
420 * @brief This compile time constant may be passed to the
421 *   rtems_task_wake_after() directive as the interval when a task wishes to
422 *   yield the processor.
423 */
424#define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT
425
426/* Generated from spec:/score/if/maximum-priority */
427
428/**
429 * @brief Returns the maximum priority of the scheduler with index zero.
430 */
431rtems_task_priority _RTEMS_Maximum_priority( void );
432
433/* Generated from spec:/rtems/task/if/maximum-priority */
434
435/**
436 * @ingroup RTEMSAPIClassicTasks
437 *
438 * @brief This constant variable provides the lowest (least important) task
439 *   priority of the first configured scheduler.
440 */
441#define RTEMS_MAXIMUM_PRIORITY _RTEMS_Maximum_priority()
442
443/* Generated from spec:/rtems/scheduler/if/ident */
444
445/**
446 * @ingroup RTEMSAPIClassicScheduler
447 *
448 * @brief Identifies a scheduler by the object name.
449 *
450 * @param name is the scheduler name to look up.
451 *
452 * @param[out] id is the pointer to an object identifier variable.  When the
453 *   directive call is successful, the identifier of the scheduler will be
454 *   stored in this variable.
455 *
456 * This directive obtains a scheduler identifier associated with the scheduler
457 * name specified in ``name``.
458 *
459 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
460 *
461 * @retval ::RTEMS_INVALID_NAME There was no scheduler associated with the
462 *   name.
463 *
464 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
465 *
466 * @par Notes
467 * @parblock
468 * The scheduler name is determined by the scheduler configuration.
469 *
470 * The scheduler identifier is used with other scheduler related directives to
471 * access the scheduler.
472 * @endparblock
473 *
474 * @par Constraints
475 * @parblock
476 * The following constraints apply to this directive:
477 *
478 * * The directive may be called from within any runtime context.
479 *
480 * * The directive will not cause the calling task to be preempted.
481 * @endparblock
482 */
483rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id );
484
485/* Generated from spec:/rtems/scheduler/if/ident-by-processor */
486
487/**
488 * @ingroup RTEMSAPIClassicScheduler
489 *
490 * @brief Identifies a scheduler by the processor index.
491 *
492 * @param cpu_index is the processor index to identify the scheduler.
493 *
494 * @param[out] id is the pointer to an object identifier variable.  When the
495 *   directive call is successful, the identifier of the scheduler will be
496 *   stored in this variable.
497 *
498 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
499 *
500 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
501 *
502 * @retval ::RTEMS_INVALID_NAME The processor index was invalid.
503 *
504 * @retval ::RTEMS_INCORRECT_STATE The processor index was valid, however, the
505 *   corresponding processor was not owned by a scheduler.
506 *
507 * @par Constraints
508 * @parblock
509 * The following constraints apply to this directive:
510 *
511 * * The directive may be called from within any runtime context.
512 *
513 * * The directive will not cause the calling task to be preempted.
514 * @endparblock
515 */
516rtems_status_code rtems_scheduler_ident_by_processor(
517  uint32_t  cpu_index,
518  rtems_id *id
519);
520
521/* Generated from spec:/rtems/scheduler/if/ident-by-processor-set */
522
523/**
524 * @ingroup RTEMSAPIClassicScheduler
525 *
526 * @brief Identifies a scheduler by the processor set.
527 *
528 * @param cpusetsize is the size of the referenced processor set variable in
529 *   bytes.  This value shall be positive.
530 *
531 * @param cpuset is the pointer to a processor set variable.  The referenced
532 *   processor set will be used to identify the scheduler.
533 *
534 * @param[out] id is the pointer to an object identifier variable.  When the
535 *   directive call is successful, the identifier of the scheduler will be
536 *   stored in this variable.
537 *
538 * The scheduler is selected according to the highest numbered online processor
539 * in the specified processor set.
540 *
541 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
542 *
543 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
544 *
545 * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL.
546 *
547 * @retval ::RTEMS_INVALID_SIZE The processor set size was invalid.
548 *
549 * @retval ::RTEMS_INVALID_NAME The processor set contained no online
550 *   processor.
551 *
552 * @retval ::RTEMS_INCORRECT_STATE The processor set was valid, however, the
553 *   highest numbered online processor in the processor set was not owned by a
554 *   scheduler.
555 *
556 * @par Constraints
557 * @parblock
558 * The following constraints apply to this directive:
559 *
560 * * The directive may be called from within any runtime context.
561 *
562 * * The directive will not cause the calling task to be preempted.
563 * @endparblock
564 */
565rtems_status_code rtems_scheduler_ident_by_processor_set(
566  size_t           cpusetsize,
567  const cpu_set_t *cpuset,
568  rtems_id        *id
569);
570
571/* Generated from spec:/rtems/scheduler/if/get-maximum-priority */
572
573/**
574 * @ingroup RTEMSAPIClassicScheduler
575 *
576 * @brief Gets the maximum task priority of the scheduler.
577 *
578 * @param scheduler_id is the scheduler identifier.
579 *
580 * @param[out] priority is the pointer to a task priority variable.  The
581 *   maximum priority of the scheduler will be stored in this variable, if the
582 *   operation is successful.
583 *
584 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
585 *
586 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
587 *   identifier specified by ``scheduler_id``.
588 *
589 * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL.
590 *
591 * @par Constraints
592 * @parblock
593 * The following constraints apply to this directive:
594 *
595 * * The directive may be called from within any runtime context.
596 *
597 * * The directive will not cause the calling task to be preempted.
598 * @endparblock
599 */
600rtems_status_code rtems_scheduler_get_maximum_priority(
601  rtems_id             scheduler_id,
602  rtems_task_priority *priority
603);
604
605/* Generated from spec:/rtems/scheduler/if/map-priority-to-posix */
606
607/**
608 * @ingroup RTEMSAPIClassicScheduler
609 *
610 * @brief Maps a Classic API task priority to the corresponding POSIX thread
611 *   priority.
612 *
613 * @param scheduler_id is the scheduler identifier.
614 *
615 * @param priority is the Classic API task priority to map.
616 *
617 * @param[out] posix_priority is the pointer to a POSIX thread priority
618 *   variable.  When the directive call is successful, the POSIX thread
619 *   priority value corresponding to the specified Classic API task priority
620 *   value will be stored in this variable.
621 *
622 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
623 *
624 * @retval ::RTEMS_INVALID_ADDRESS The ``posix_priority`` parameter was NULL.
625 *
626 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
627 *   identifier specified by ``scheduler_id``.
628 *
629 * @retval ::RTEMS_INVALID_PRIORITY The Classic API task priority was invalid.
630 *
631 * @par Constraints
632 * @parblock
633 * The following constraints apply to this directive:
634 *
635 * * The directive may be called from within any runtime context.
636 *
637 * * The directive will not cause the calling task to be preempted.
638 * @endparblock
639 */
640rtems_status_code rtems_scheduler_map_priority_to_posix(
641  rtems_id            scheduler_id,
642  rtems_task_priority priority,
643  int                *posix_priority
644);
645
646/* Generated from spec:/rtems/scheduler/if/map-priority-from-posix */
647
648/**
649 * @ingroup RTEMSAPIClassicScheduler
650 *
651 * @brief Maps a POSIX thread priority to the corresponding Classic API task
652 *   priority.
653 *
654 * @param scheduler_id is the scheduler identifier.
655 *
656 * @param posix_priority is the POSIX thread priority to map.
657 *
658 * @param[out] priority is the pointer to a Classic API task priority variable.
659 *   When the directive call is successful, the Classic API task priority value
660 *   corresponding to the specified POSIX thread priority value will be stored
661 *   in this variable.
662 *
663 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
664 *
665 * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL.
666 *
667 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
668 *   identifier specified by ``scheduler_id``.
669 *
670 * @retval ::RTEMS_INVALID_PRIORITY The POSIX thread priority was invalid.
671 *
672 * @par Constraints
673 * @parblock
674 * The following constraints apply to this directive:
675 *
676 * * The directive may be called from within any runtime context.
677 *
678 * * The directive will not cause the calling task to be preempted.
679 * @endparblock
680 */
681rtems_status_code rtems_scheduler_map_priority_from_posix(
682  rtems_id             scheduler_id,
683  int                  posix_priority,
684  rtems_task_priority *priority
685);
686
687/* Generated from spec:/rtems/scheduler/if/get-processor */
688
689/**
690 * @ingroup RTEMSAPIClassicScheduler
691 *
692 * @brief Returns the index of the current processor.
693 *
694 * Where the system was built with SMP support disabled, this directive
695 * evaluates to a compile time constant of zero.
696 *
697 * Where the system was built with SMP support enabled, this directive returns
698 * the index of the current processor.  The set of processor indices is the
699 * range of integers starting with zero up to
700 * rtems_scheduler_get_processor_maximum() minus one.
701 *
702 * @return Returns the index of the current processor.
703 *
704 * @par Notes
705 * Outside of sections with disabled thread dispatching the current processor
706 * index may change after every instruction since the thread may migrate from
707 * one processor to another.  Sections with disabled interrupts are sections
708 * with thread dispatching disabled.
709 *
710 * @par Constraints
711 * @parblock
712 * The following constraints apply to this directive:
713 *
714 * * The directive may be called from within any runtime context.
715 *
716 * * The directive will not cause the calling task to be preempted.
717 * @endparblock
718 */
719uint32_t rtems_scheduler_get_processor( void );
720
721/* Generated from spec:/rtems/scheduler/if/get-processor-macro */
722#define rtems_scheduler_get_processor() _SMP_Get_current_processor()
723
724/* Generated from spec:/rtems/scheduler/if/get-processor-maximum */
725
726/**
727 * @ingroup RTEMSAPIClassicScheduler
728 *
729 * @brief Returns the processor maximum supported by the system.
730 *
731 * Where the system was built with SMP support disabled, this directive
732 * evaluates to a compile time constant of one.
733 *
734 * Where the system was built with SMP support enabled, this directive returns
735 * the minimum of the processors (physically or virtually) available at the
736 * target and the configured processor maximum (see
737 * #CONFIGURE_MAXIMUM_PROCESSORS).  Not all processors in the range from
738 * processor index zero to the last processor index (which is the processor
739 * maximum minus one) may be configured to be used by a scheduler or may be
740 * online (online processors have a scheduler assigned).
741 *
742 * @return Returns the processor maximum supported by the system.
743 *
744 * @par Constraints
745 * @parblock
746 * The following constraints apply to this directive:
747 *
748 * * The directive may be called from within any runtime context.
749 *
750 * * The directive will not cause the calling task to be preempted.
751 * @endparblock
752 */
753uint32_t rtems_scheduler_get_processor_maximum( void );
754
755/* Generated from spec:/rtems/scheduler/if/get-processor-maximum-macro */
756#define rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum()
757
758/* Generated from spec:/rtems/scheduler/if/get-processor-set */
759
760/**
761 * @ingroup RTEMSAPIClassicScheduler
762 *
763 * @brief Gets the set of processors owned by the scheduler.
764 *
765 * @param scheduler_id is the scheduler identifier.
766 *
767 * @param cpusetsize is the size of the referenced processor set variable in
768 *   bytes.
769 *
770 * @param[out] cpuset is the pointer to a processor set variable.  When the
771 *   directive call is successful, the processor set of the scheduler will be
772 *   stored in this variable.  A set bit in the processor set means that the
773 *   corresponding processor is owned by the scheduler, otherwise the bit is
774 *   cleared.
775 *
776 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
777 *
778 * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL.
779 *
780 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
781 *   identifier specified by ``scheduler_id``.
782 *
783 * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for
784 *   the set of processors owned by the scheduler.
785 *
786 * @par Constraints
787 * @parblock
788 * The following constraints apply to this directive:
789 *
790 * * The directive may be called from within any runtime context.
791 *
792 * * The directive will not cause the calling task to be preempted.
793 * @endparblock
794 */
795rtems_status_code rtems_scheduler_get_processor_set(
796  rtems_id   scheduler_id,
797  size_t     cpusetsize,
798  cpu_set_t *cpuset
799);
800
801/* Generated from spec:/rtems/scheduler/if/add-processor */
802
803/**
804 * @ingroup RTEMSAPIClassicScheduler
805 *
806 * @brief Adds the processor to the set of processors owned by the scheduler.
807 *
808 * @param scheduler_id is the scheduler identifier.
809 *
810 * @param cpu_index is the index of the processor to add.
811 *
812 * This directive adds the processor specified by the ``cpu_index`` to the
813 * scheduler specified by ``scheduler_id``.
814 *
815 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
816 *
817 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
818 *   identifier specified by ``scheduler_id``.
819 *
820 * @retval ::RTEMS_NOT_CONFIGURED The processor was not configured to be used
821 *   by the application.
822 *
823 * @retval ::RTEMS_INCORRECT_STATE The processor was configured to be used by
824 *   the application, however, it was not online.
825 *
826 * @retval ::RTEMS_RESOURCE_IN_USE The processor was already assigned to a
827 *   scheduler.
828 *
829 * @par Constraints
830 * @parblock
831 * The following constraints apply to this directive:
832 *
833 * * The directive may be called from within device driver initialization
834 *   context.
835 *
836 * * The directive may be called from within task context.
837 *
838 * * The directive may obtain and release the object allocator mutex.  This may
839 *   cause the calling task to be preempted.
840 * @endparblock
841 */
842rtems_status_code rtems_scheduler_add_processor(
843  rtems_id scheduler_id,
844  uint32_t cpu_index
845);
846
847/* Generated from spec:/rtems/scheduler/if/remove-processor */
848
849/**
850 * @ingroup RTEMSAPIClassicScheduler
851 *
852 * @brief Removes the processor from the set of processors owned by the
853 *   scheduler.
854 *
855 * @param scheduler_id is the scheduler identifier.
856 *
857 * @param cpu_index is the index of the processor to remove.
858 *
859 * This directive removes the processor specified by the ``cpu_index`` from the
860 * scheduler specified by ``scheduler_id``.
861 *
862 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
863 *
864 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
865 *   identifier specified by ``scheduler_id``.
866 *
867 * @retval ::RTEMS_INVALID_NUMBER The processor was not owned by the scheduler.
868 *
869 * @retval ::RTEMS_RESOURCE_IN_USE The set of processors owned by the scheduler
870 *   would have been empty after the processor removal and there was at least
871 *   one non-idle task that used this scheduler as its home scheduler.
872 *
873 * @par Notes
874 * Removing a processor from a scheduler is a complex operation that involves
875 * all tasks of the system.
876 *
877 * @par Constraints
878 * @parblock
879 * The following constraints apply to this directive:
880 *
881 * * The directive may be called from within device driver initialization
882 *   context.
883 *
884 * * The directive may be called from within task context.
885 *
886 * * The directive may obtain and release the object allocator mutex.  This may
887 *   cause the calling task to be preempted.
888 * @endparblock
889 */
890rtems_status_code rtems_scheduler_remove_processor(
891  rtems_id scheduler_id,
892  uint32_t cpu_index
893);
894
895/* Generated from spec:/rtems/task/if/create */
896
897/**
898 * @ingroup RTEMSAPIClassicTasks
899 *
900 * @brief Creates a task.
901 *
902 * @param name is the object name of the task.
903 *
904 * @param initial_priority is the initial task priority.
905 *
906 * @param stack_size is the task stack size in bytes.
907 *
908 * @param initial_modes is the initial mode set of the task.
909 *
910 * @param attribute_set is the attribute set of the task.
911 *
912 * @param[out] id is the pointer to an object identifier variable.  When the
913 *   directive call is successful, the identifier of the created task will be
914 *   stored in this variable.
915 *
916 * This directive creates a task which resides on the local node.  The task has
917 * the user-defined object name specified in ``name``.  The assigned object
918 * identifier is returned in ``id``.  This identifier is used to access the
919 * task with other task related directives.
920 *
921 * The **initial priority** of the task is specified in ``initial_priority``.
922 * The scheduler of the created task is the scheduler of the calling task at
923 * some point during the task creation.  The initial task priority specified in
924 * ``initial_priority`` shall be valid for this scheduler.
925 *
926 * The **stack size** of the task is specified in ``stack_size``.  If the
927 * requested stack size is less than the configured minimum stack size, then
928 * RTEMS will use the configured minimum as the stack size for this task.  The
929 * configured minimum stack size is defined by the
930 * #CONFIGURE_MINIMUM_TASK_STACK_SIZE application configuration option.  In
931 * addition to being able to specify the task stack size as a integer, there
932 * are two constants which may be specified:
933 *
934 * * The #RTEMS_MINIMUM_STACK_SIZE constant can be specified to use the
935 *   **recommended minimum stack size** for the target processor.  This value
936 *   is selected by the RTEMS maintainers conservatively to minimize the risk
937 *   of blown stacks for most user applications.  Using this constant when
938 *   specifying the task stack size, indicates that the stack size will be at
939 *   least #RTEMS_MINIMUM_STACK_SIZE bytes in size.  If the user configured
940 *   minimum stack size is larger than the recommended minimum, then it will be
941 *   used.
942 *
943 * * The #RTEMS_CONFIGURED_MINIMUM_STACK_SIZE constant can be specified to use
944 *   the minimum stack size that was configured by the application.  If not
945 *   explicitly configured by the application, the default configured minimum
946 *   stack size is the target processor dependent value
947 *   #RTEMS_MINIMUM_STACK_SIZE.  Since this uses the configured minimum stack
948 *   size value, you may get a stack size that is smaller or larger than the
949 *   recommended minimum.  This can be used to provide large stacks for all
950 *   tasks on complex applications or small stacks on applications that are
951 *   trying to conserve memory.
952 *
953 * The **initial mode set** specified in ``initial_modes`` is built through a
954 * *bitwise or* of the mode constants described below.  Not all combinations of
955 * modes are allowed.  Some modes are mutually exclusive.  If mutually
956 * exclusive modes are combined, the behaviour is undefined.  Default task
957 * modes can be selected by using the #RTEMS_DEFAULT_MODES constant.  The task
958 * mode set defines
959 *
960 * * the preemption mode of the task: #RTEMS_PREEMPT (default) or
961 *   #RTEMS_NO_PREEMPT,
962 *
963 * * the timeslicing mode of the task: #RTEMS_TIMESLICE or #RTEMS_NO_TIMESLICE
964 *   (default),
965 *
966 * * the ASR processing mode of the task: #RTEMS_ASR (default) or
967 *   #RTEMS_NO_ASR,
968 *
969 * * the interrupt level of the task: RTEMS_INTERRUPT_LEVEL() with a default of
970 *   ``RTEMS_INTERRUPT_LEVEL( 0 )`` which is associated with enabled
971 *   interrupts.
972 *
973 * The **initial preemption mode** of the task is enabled or disabled.
974 *
975 * * An **enabled preemption** is the default and can be emphasized through the
976 *   use of the #RTEMS_PREEMPT mode constant.
977 *
978 * * A **disabled preemption** is set by the #RTEMS_NO_PREEMPT mode constant.
979 *
980 * The **initial timeslicing mode** of the task is enabled or disabled.
981 *
982 * * A **disabled timeslicing** is the default and can be emphasized through
983 *   the use of the #RTEMS_NO_TIMESLICE mode constant.
984 *
985 * * An **enabled timeslicing** is set by the #RTEMS_TIMESLICE mode constant.
986 *
987 * The **initial ASR processing mode** of the task is enabled or disabled.
988 *
989 * * An **enabled ASR processing** is the default and can be emphasized through
990 *   the use of the #RTEMS_ASR mode constant.
991 *
992 * * A **disabled ASR processing** is set by the #RTEMS_NO_ASR mode constant.
993 *
994 * The **initial interrupt level mode** of the task is defined by
995 * RTEMS_INTERRUPT_LEVEL().
996 *
997 * * Task execution with **interrupts enabled** the default and can be
998 *   emphasized through the use of the RTEMS_INTERRUPT_LEVEL() mode macro with
999 *   a value of zero (0) for the parameter.  An interrupt level of zero is
1000 *   associated with enabled interrupts on all target processors.
1001 *
1002 * * Task execution at a **non-zero interrupt level** can be specified by the
1003 *   RTEMS_INTERRUPT_LEVEL() mode macro with a non-zero value for the
1004 *   parameter.  The interrupt level portion of the task mode supports a
1005 *   maximum of 256 interrupt levels.  These levels are mapped onto the
1006 *   interrupt levels actually supported by the target processor in a processor
1007 *   dependent fashion.
1008 *
1009 * The **attribute set** specified in ``attribute_set`` is built through a
1010 * *bitwise or* of the attribute constants described below.  Not all
1011 * combinations of attributes are allowed.  Some attributes are mutually
1012 * exclusive.  If mutually exclusive attributes are combined, the behaviour is
1013 * undefined.  Attributes not mentioned below are not evaluated by this
1014 * directive and have no effect.  Default attributes can be selected by using
1015 * the #RTEMS_DEFAULT_ATTRIBUTES constant.  The attribute set defines
1016 *
1017 * * the scope of the task: #RTEMS_LOCAL (default) or #RTEMS_GLOBAL and
1018 *
1019 * * the floating-point unit use of the task: #RTEMS_FLOATING_POINT or
1020 *   #RTEMS_NO_FLOATING_POINT (default).
1021 *
1022 * The task has a local or global **scope** in a multiprocessing network (this
1023 * attribute does not refer to SMP systems).  The scope is selected by the
1024 * mutually exclusive #RTEMS_LOCAL and #RTEMS_GLOBAL attributes.
1025 *
1026 * * A **local scope** is the default and can be emphasized through the use of
1027 *   the #RTEMS_LOCAL attribute.  A local task can be only used by the node
1028 *   which created it.
1029 *
1030 * * A **global scope** is established if the #RTEMS_GLOBAL attribute is set.
1031 *   Setting the global attribute in a single node system has no effect.the
1032 *
1033 * The **use of the floating-point unit** is selected by the mutually exclusive
1034 * #RTEMS_FLOATING_POINT and #RTEMS_NO_FLOATING_POINT attributes.  On some
1035 * target processors, the use of the floating-point unit can be enabled or
1036 * disabled for each task.  Other target processors may have no hardware
1037 * floating-point unit or enable the use of the floating-point unit for all
1038 * tasks.  Consult the *RTEMS CPU Architecture Supplement* for the details.
1039 *
1040 * * A **disabled floating-point unit** is the default and can be emphasized
1041 *   through use of the #RTEMS_NO_FLOATING_POINT attribute.  For performance
1042 *   reasons, it is recommended that tasks not using the floating-point unit
1043 *   should specify this attribute.
1044 *
1045 * * An **enabled floating-point unit** is selected by the
1046 *   #RTEMS_FLOATING_POINT attribute.
1047 *
1048 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1049 *
1050 * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was invalid.
1051 *
1052 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
1053 *
1054 * @retval ::RTEMS_INVALID_PRIORITY The ``initial_priority`` was invalid.
1055 *
1056 * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a
1057 *   task.  The number of tasks available to the application is configured
1058 *   through the #CONFIGURE_MAXIMUM_TASKS application configuration option.
1059 *
1060 * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no
1061 *   inactive global object available to create a global task.  The number of
1062 *   global objects available to the application is configured through the
1063 *   #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option.
1064 *
1065 * @retval ::RTEMS_UNSATISFIED There was not enough memory to allocate the task
1066 *   storage area.  The task storage area contains the task stack, the
1067 *   thread-local storage, and the floating point context.
1068 *
1069 * @retval ::RTEMS_UNSATISFIED One of the task create extensions failed to
1070 *   create the task.
1071 *
1072 * @retval ::RTEMS_UNSATISFIED In SMP configurations, the non-preemption mode
1073 *   was not supported.
1074 *
1075 * @retval ::RTEMS_UNSATISFIED In SMP configurations, the interrupt level mode
1076 *   was not supported.
1077 *
1078 * @par Notes
1079 * @parblock
1080 * The task processor affinity is initialized to the set of online processors.
1081 *
1082 * When created, a task is placed in the dormant state and can only be made
1083 * ready to execute using the directive rtems_task_start().
1084 *
1085 * Application developers should consider the stack usage of the device drivers
1086 * when calculating the stack size required for tasks which utilize the driver.
1087 * The task stack size shall account for an target processor dependent
1088 * interrupt stack frame which may be placed on the stack of the interrupted
1089 * task while servicing an interrupt.  The stack checker may be used to monitor
1090 * the stack usage, see #CONFIGURE_STACK_CHECKER_ENABLED.
1091 *
1092 * For control and maintenance of the task, RTEMS allocates a TCB from the
1093 * local TCB free pool and initializes it.
1094 *
1095 * The TCB for a global task is allocated on the local node.  Task should not
1096 * be made global unless remote tasks must interact with the task.  This is to
1097 * avoid the system overhead incurred by the creation of a global task.  When a
1098 * global task is created, the task's name and identifier must be transmitted
1099 * to every node in the system for insertion in the local copy of the global
1100 * object table.
1101 * @endparblock
1102 *
1103 * @par Constraints
1104 * @parblock
1105 * The following constraints apply to this directive:
1106 *
1107 * * The directive may be called from within device driver initialization
1108 *   context.
1109 *
1110 * * The directive may be called from within task context.
1111 *
1112 * * The directive may obtain and release the object allocator mutex.  This may
1113 *   cause the calling task to be preempted.
1114 *
1115 * * When the directive operates on a global object, the directive sends a
1116 *   message to remote nodes.  This may preempt the calling task.
1117 *
1118 * * The number of tasks available to the application is configured through the
1119 *   #CONFIGURE_MAXIMUM_TASKS application configuration option.
1120 *
1121 * * Where the object class corresponding to the directive is configured to use
1122 *   unlimited objects, the directive may allocate memory from the RTEMS
1123 *   Workspace.
1124 *
1125 * * The number of global objects available to the application is configured
1126 *   through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration
1127 *   option.
1128 * @endparblock
1129 */
1130rtems_status_code rtems_task_create(
1131  rtems_name          name,
1132  rtems_task_priority initial_priority,
1133  size_t              stack_size,
1134  rtems_mode          initial_modes,
1135  rtems_attribute     attribute_set,
1136  rtems_id           *id
1137);
1138
1139/* Generated from spec:/rtems/task/if/construct */
1140
1141/**
1142 * @ingroup RTEMSAPIClassicTasks
1143 *
1144 * @brief Constructs a task from the specified task configuration.
1145 *
1146 * @param config is the task configuration.
1147 *
1148 * @param[out] id is the pointer to an object identifier variable.  When the
1149 *   directive call is successful, the identifier of the constructed task will
1150 *   be stored in this variable.
1151 *
1152 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1153 *
1154 * @retval ::RTEMS_INVALID_ADDRESS The ``config`` parameter was NULL.
1155 *
1156 * @retval ::RTEMS_INVALID_NAME The task name was invalid.
1157 *
1158 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
1159 *
1160 * @retval ::RTEMS_INVALID_PRIORITY The initial task priority was invalid.
1161 *
1162 * @retval ::RTEMS_INVALID_SIZE The thread-local storage size is greater than
1163 *   the maximum thread-local storage size specified in the task configuration.
1164 *   The thread-local storage size is determined by the thread-local variables
1165 *   used by the application and #CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE.
1166 *
1167 * @retval ::RTEMS_INVALID_SIZE The task storage area was too small to provide
1168 *   a task stack of the configured minimum size, see
1169 *   #CONFIGURE_MINIMUM_TASK_STACK_SIZE. The task storage area contains the
1170 *   task stack, the thread-local storage, and the floating-point context on
1171 *   architectures with a separate floating-point context.
1172 *
1173 * @retval ::RTEMS_TOO_MANY There was no inactive task object available to
1174 *   construct a task.
1175 *
1176 * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no
1177 *   inactive global object available to construct a global task.
1178 *
1179 * @retval ::RTEMS_UNSATISFIED One of the task create extensions failed during
1180 *   the task construction.
1181 *
1182 * @retval ::RTEMS_UNSATISFIED In SMP configurations, the non-preemption mode
1183 *   was not supported.
1184 *
1185 * @retval ::RTEMS_UNSATISFIED In SMP configurations, the interrupt level mode
1186 *   was not supported.
1187 *
1188 * @par Notes
1189 * @parblock
1190 * In contrast to tasks created by rtems_task_create(), the tasks constructed
1191 * by this directive use a user-provided task storage area.  The task storage
1192 * area contains the task stack, the thread-local storage, and the
1193 * floating-point context on architectures with a separate floating-point
1194 * context.
1195 *
1196 * This directive is intended for applications which do not want to use the
1197 * RTEMS Workspace and instead statically allocate all operating system
1198 * resources.  It is not recommended to use rtems_task_create() and
1199 * rtems_task_construct() together in an application.  It is also not
1200 * recommended to use rtems_task_construct() for drivers or general purpose
1201 * libraries.  The reason for these recommendations is that the task
1202 * configuration needs settings which can be only given with a through
1203 * knowledge of the application resources.
1204 *
1205 * An application based solely on static allocation can avoid any runtime
1206 * memory allocators.  This can simplify the application architecture as well
1207 * as any analysis that may be required.
1208 *
1209 * The stack space estimate done by <rtems/confdefs.h> assumes that all tasks
1210 * are created by rtems_task_create().  The estimate can be adjusted to take
1211 * user-provided task storage areas into account through the
1212 * #CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE application
1213 * configuration option.
1214 *
1215 * The #CONFIGURE_MAXIMUM_TASKS should include tasks constructed by
1216 * rtems_task_construct().
1217 * @endparblock
1218 *
1219 * @par Constraints
1220 * @parblock
1221 * The following constraints apply to this directive:
1222 *
1223 * * The directive may be called from within device driver initialization
1224 *   context.
1225 *
1226 * * The directive may be called from within task context.
1227 *
1228 * * The directive may obtain and release the object allocator mutex.  This may
1229 *   cause the calling task to be preempted.
1230 *
1231 * * When the directive operates on a global object, the directive sends a
1232 *   message to remote nodes.  This may preempt the calling task.
1233 *
1234 * * The number of tasks available to the application is configured through the
1235 *   #CONFIGURE_MAXIMUM_TASKS application configuration option.
1236 *
1237 * * Where the object class corresponding to the directive is configured to use
1238 *   unlimited objects, the directive may allocate memory from the RTEMS
1239 *   Workspace.
1240 *
1241 * * The number of global objects available to the application is configured
1242 *   through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration
1243 *   option.
1244 * @endparblock
1245 */
1246rtems_status_code rtems_task_construct(
1247  const rtems_task_config *config,
1248  rtems_id                *id
1249);
1250
1251/* Generated from spec:/rtems/task/if/ident */
1252
1253/**
1254 * @ingroup RTEMSAPIClassicTasks
1255 *
1256 * @brief Identifies a task by the object name.
1257 *
1258 * @param name is the object name to look up.
1259 *
1260 * @param node is the node or node set to search for a matching object.
1261 *
1262 * @param[out] id is the pointer to an object identifier variable.  When the
1263 *   directive call is successful, the object identifier of an object with the
1264 *   specified name will be stored in this variable.
1265 *
1266 * This directive obtains a task identifier associated with the task name
1267 * specified in ``name``.
1268 *
1269 * A task may obtain its own identifier by specifying #RTEMS_SELF for the name.
1270 *
1271 * The node to search is specified in ``node``.  It shall be
1272 *
1273 * * a valid node number,
1274 *
1275 * * the constant #RTEMS_SEARCH_ALL_NODES to search in all nodes,
1276 *
1277 * * the constant #RTEMS_SEARCH_LOCAL_NODE to search in the local node only, or
1278 *
1279 * * the constant #RTEMS_SEARCH_OTHER_NODES to search in all nodes except the
1280 *   local node.
1281 *
1282 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1283 *
1284 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
1285 *
1286 * @retval ::RTEMS_INVALID_NAME There was no object with the specified name on
1287 *   the specified nodes.
1288 *
1289 * @retval ::RTEMS_INVALID_NODE In multiprocessing configurations, the
1290 *   specified node was invalid.
1291 *
1292 * @par Notes
1293 * @parblock
1294 * If the task name is not unique, then the task identifier will match the
1295 * first task with that name in the search order.  However, this task
1296 * identifier is not guaranteed to correspond to the desired task.
1297 *
1298 * The objects are searched from lowest to the highest index.  If ``node`` is
1299 * #RTEMS_SEARCH_ALL_NODES, all nodes are searched with the local node being
1300 * searched first.  All other nodes are searched from lowest to the highest
1301 * node number.
1302 *
1303 * If node is a valid node number which does not represent the local node, then
1304 * only the tasks exported by the designated node are searched.
1305 *
1306 * This directive does not generate activity on remote nodes.  It accesses only
1307 * the local copy of the global object table.
1308 *
1309 * The task identifier is used with other task related directives to access the
1310 * task.
1311 * @endparblock
1312 *
1313 * @par Constraints
1314 * @parblock
1315 * The following constraints apply to this directive:
1316 *
1317 * * The directive may be called from within any runtime context.
1318 *
1319 * * The directive will not cause the calling task to be preempted.
1320 * @endparblock
1321 */
1322rtems_status_code rtems_task_ident(
1323  rtems_name name,
1324  uint32_t   node,
1325  rtems_id  *id
1326);
1327
1328/* Generated from spec:/rtems/task/if/self */
1329
1330/**
1331 * @ingroup RTEMSAPIClassicTasks
1332 *
1333 * @brief Gets the task identifier of the calling task.
1334 *
1335 * This directive returns the task identifier of the calling task.
1336 *
1337 * @return Returns the task identifier of the calling task.
1338 *
1339 * @par Constraints
1340 * @parblock
1341 * The following constraints apply to this directive:
1342 *
1343 * * The directive may be called from within device driver initialization
1344 *   context.
1345 *
1346 * * The directive may be called from within task context.
1347 *
1348 * * The directive will not cause the calling task to be preempted.
1349 * @endparblock
1350 */
1351rtems_id rtems_task_self( void );
1352
1353/* Generated from spec:/rtems/task/if/start */
1354
1355/**
1356 * @ingroup RTEMSAPIClassicTasks
1357 *
1358 * @brief Starts the task.
1359 *
1360 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
1361 *   specify the calling task.
1362 *
1363 * @param entry_point is the task entry point.
1364 *
1365 * @param argument is the task entry point argument.
1366 *
1367 * This directive readies the task, specified by ``id``, for execution based on
1368 * the priority and execution mode specified when the task was created.  The
1369 * entry point of the task is given in ``entry_point``. The task's entry point
1370 * argument is contained in ``argument``.
1371 *
1372 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1373 *
1374 * @retval ::RTEMS_INVALID_ADDRESS The ``entry_point`` parameter was NULL.
1375 *
1376 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1377 *   specified by ``id``.
1378 *
1379 * @retval ::RTEMS_INCORRECT_STATE The task was not in the dormant state.
1380 *
1381 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
1382 *
1383 * @par Notes
1384 * @parblock
1385 * The type of the entry point argument is an unsigned integer type.  However,
1386 * the integer type has the property that any valid pointer to ``void`` can be
1387 * converted to this type and then converted back to a pointer to ``void``.
1388 * The result will compare equal to the original pointer.  The type can
1389 * represent at least 32 bits.  Some applications use the entry point argument
1390 * as an index into a parameter table to get task-specific parameters.
1391 *
1392 * Any actions performed on a dormant task such as suspension or change of
1393 * priority are nullified when the task is initiated via the rtems_task_start()
1394 * directive.
1395 * @endparblock
1396 *
1397 * @par Constraints
1398 * @parblock
1399 * The following constraints apply to this directive:
1400 *
1401 * * The directive may be called from within interrupt context.
1402 *
1403 * * The directive may be called from within device driver initialization
1404 *   context.
1405 *
1406 * * The directive may be called from within task context.
1407 *
1408 * * The directive may unblock a task.  This may cause the calling task to be
1409 *   preempted.
1410 * @endparblock
1411 */
1412rtems_status_code rtems_task_start(
1413  rtems_id            id,
1414  rtems_task_entry    entry_point,
1415  rtems_task_argument argument
1416);
1417
1418/* Generated from spec:/rtems/task/if/restart */
1419
1420/**
1421 * @ingroup RTEMSAPIClassicTasks
1422 *
1423 * @brief Restarts the task.
1424 *
1425 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
1426 *   specify the calling task.
1427 *
1428 * @param argument is the task entry point argument.
1429 *
1430 * This directive resets the task specified by ``id`` to begin execution at its
1431 * original entry point.  The task's priority and execution mode are set to the
1432 * original creation values.  If the task is currently blocked, RTEMS
1433 * automatically makes the task ready.  A task can be restarted from any state,
1434 * except the dormant state.  The task's entry point argument is contained in
1435 * ``argument``.
1436 *
1437 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1438 *
1439 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1440 *   specified by ``id``.
1441 *
1442 * @retval ::RTEMS_INCORRECT_STATE The task never started.
1443 *
1444 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
1445 *
1446 * @par Notes
1447 * @parblock
1448 * The type of the entry point argument is an unsigned integer type.  However,
1449 * the integer type has the property that any valid pointer to ``void`` can be
1450 * converted to this type and then converted back to a pointer to ``void``.
1451 * The result will compare equal to the original pointer.  The type can
1452 * represent at least 32 bits.  Some applications use the entry point argument
1453 * as an index into a parameter table to get task-specific parameters.
1454 *
1455 * A new entry point argument may be used to distinguish between the initial
1456 * rtems_task_start() of the task and any ensuing calls to rtems_task_restart()
1457 * of the task.  This can be beneficial in deleting a task.  Instead of
1458 * deleting a task using the rtems_task_delete() directive, a task can delete
1459 * another task by restarting that task, and allowing that task to release
1460 * resources back to RTEMS and then delete itself.
1461 * @endparblock
1462 *
1463 * @par Constraints
1464 * @parblock
1465 * The following constraints apply to this directive:
1466 *
1467 * * The directive may be called from within interrupt context.
1468 *
1469 * * The directive may be called from within device driver initialization
1470 *   context.
1471 *
1472 * * The directive may be called from within task context.
1473 *
1474 * * The directive may change the priority of a task.  This may cause the
1475 *   calling task to be preempted.
1476 *
1477 * * The directive may unblock a task.  This may cause the calling task to be
1478 *   preempted.
1479 * @endparblock
1480 */
1481rtems_status_code rtems_task_restart(
1482  rtems_id            id,
1483  rtems_task_argument argument
1484);
1485
1486/* Generated from spec:/rtems/task/if/delete */
1487
1488/**
1489 * @ingroup RTEMSAPIClassicTasks
1490 *
1491 * @brief Deletes the task.
1492 *
1493 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
1494 *   specify the calling task.
1495 *
1496 * This directive deletes the task, either the calling task or another task, as
1497 * specified by ``id``.
1498 *
1499 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1500 *
1501 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1502 *   specified by ``id``.
1503 *
1504 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
1505 *
1506 * @par Notes
1507 * @parblock
1508 * RTEMS stops the execution of the task and reclaims the stack memory, any
1509 * allocated delay or timeout timers, the TCB, and, if the task is
1510 * #RTEMS_FLOATING_POINT, its floating point context area. RTEMS explicitly
1511 * does not reclaim the following resources: region segments, partition
1512 * buffers, semaphores, timers, or rate monotonic periods.
1513 *
1514 * A task is responsible for releasing its resources back to RTEMS before
1515 * deletion.  To insure proper deallocation of resources, a task should not be
1516 * deleted unless it is unable to execute or does not hold any RTEMS resources.
1517 * If a task holds RTEMS resources, the task should be allowed to deallocate
1518 * its resources before deletion.  A task can be directed to release its
1519 * resources and delete itself by restarting it with a special argument or by
1520 * sending it a message, an event, or a signal.
1521 *
1522 * Deletion of the current task (#RTEMS_SELF) will force RTEMS to select
1523 * another task to execute.
1524 *
1525 * The TCB for the deleted task is reclaimed by RTEMS.
1526 *
1527 * When a global task is deleted, the task identifier must be transmitted to
1528 * every node in the system for deletion from the local copy of the global
1529 * object table.
1530 *
1531 * The task must reside on the local node, even if the task was created with
1532 * the #RTEMS_GLOBAL attribute.
1533 * @endparblock
1534 *
1535 * @par Constraints
1536 * @parblock
1537 * The following constraints apply to this directive:
1538 *
1539 * * The directive may be called from within device driver initialization
1540 *   context.
1541 *
1542 * * The directive may be called from within task context.
1543 *
1544 * * The directive may obtain and release the object allocator mutex.  This may
1545 *   cause the calling task to be preempted.
1546 *
1547 * * When the directive operates on a global object, the directive sends a
1548 *   message to remote nodes.  This may preempt the calling task.
1549 *
1550 * * The calling task does not have to be the task that created the object.
1551 *   Any local task that knows the object identifier can delete the object.
1552 *
1553 * * Where the object class corresponding to the directive is configured to use
1554 *   unlimited objects, the directive may free memory to the RTEMS Workspace.
1555 * @endparblock
1556 */
1557rtems_status_code rtems_task_delete( rtems_id id );
1558
1559/* Generated from spec:/rtems/task/if/exit */
1560
1561/**
1562 * @ingroup RTEMSAPIClassicTasks
1563 *
1564 * @brief Deletes the calling task.
1565 *
1566 * This directive deletes the calling task.
1567 *
1568 * @par Notes
1569 * @parblock
1570 * The directive is an optimized variant of the following code sequences, see
1571 * also rtems_task_delete():
1572 *
1573 * @code
1574 * #include <pthread.h>
1575 * #include <rtems.h>
1576 *
1577 * void classic_delete_self( void )
1578 * {
1579 *   (void) rtems_task_delete( RTEMS_SELF );
1580 * }
1581 *
1582 * void posix_delete_self( void )
1583 * {
1584 *   (void) pthread_detach( pthread_self() );
1585 *   (void) pthread_exit( NULL);
1586 * }
1587 * @endcode
1588 * @endparblock
1589 *
1590 * @par Constraints
1591 * @parblock
1592 * The following constraints apply to this directive:
1593 *
1594 * * The directive may be called from within task context.
1595 *
1596 * * The directive will not return to the caller.
1597 *
1598 * * While thread dispatching is disabled, if the directive performs a thread
1599 *   dispatch, then the fatal error with the fatal source INTERNAL_ERROR_CORE
1600 *   and the fatal code INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will
1601 *   occur.
1602 * @endparblock
1603 */
1604RTEMS_NO_RETURN void rtems_task_exit( void );
1605
1606/* Generated from spec:/rtems/task/if/suspend */
1607
1608/**
1609 * @ingroup RTEMSAPIClassicTasks
1610 *
1611 * @brief Suspends the task.
1612 *
1613 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
1614 *   specify the calling task.
1615 *
1616 * This directive suspends the task specified by ``id`` from further execution
1617 * by placing it in the suspended state.  This state is additive to any other
1618 * blocked state that the task may already be in.  The task will not execute
1619 * again until another task issues the rtems_task_resume() directive for this
1620 * task and any blocked state has been removed.  The rtems_task_restart()
1621 * directive will also remove the suspended state.
1622 *
1623 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1624 *
1625 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1626 *   specified by ``id``.
1627 *
1628 * @retval ::RTEMS_ALREADY_SUSPENDED The task was already suspended.
1629 *
1630 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
1631 *
1632 * @par Notes
1633 * The requesting task can suspend itself for example by specifying #RTEMS_SELF
1634 * as ``id``.  In this case, the task will be suspended and a successful return
1635 * code will be returned when the task is resumed.
1636 *
1637 * @par Constraints
1638 * @parblock
1639 * The following constraints apply to this directive:
1640 *
1641 * * The directive may be called from within interrupt context.
1642 *
1643 * * The directive may be called from within device driver initialization
1644 *   context.
1645 *
1646 * * The directive may be called from within task context.
1647 *
1648 * * When the directive operates on a remote object, the directive sends a
1649 *   message to the remote node and waits for a reply.  This will preempt the
1650 *   calling task.
1651 * @endparblock
1652 */
1653rtems_status_code rtems_task_suspend( rtems_id id );
1654
1655/* Generated from spec:/rtems/task/if/resume */
1656
1657/**
1658 * @ingroup RTEMSAPIClassicTasks
1659 *
1660 * @brief Resumes the task.
1661 *
1662 * @param id is the task identifier.
1663 *
1664 * This directive removes the task specified by ``id`` from the suspended
1665 * state.  If the task is in the ready state after the suspension is removed,
1666 * then it will be scheduled to run.  If the task is still in a blocked state
1667 * after the suspension is removed, then it will remain in that blocked state.
1668 *
1669 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1670 *
1671 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1672 *   specified by ``id``.
1673 *
1674 * @retval ::RTEMS_INCORRECT_STATE The task was not suspended.
1675 *
1676 * @par Constraints
1677 * @parblock
1678 * The following constraints apply to this directive:
1679 *
1680 * * The directive may be called from within interrupt context.
1681 *
1682 * * The directive may be called from within device driver initialization
1683 *   context.
1684 *
1685 * * The directive may be called from within task context.
1686 *
1687 * * The directive may unblock a task.  This may cause the calling task to be
1688 *   preempted.
1689 *
1690 * * When the directive operates on a remote object, the directive sends a
1691 *   message to the remote node and waits for a reply.  This will preempt the
1692 *   calling task.
1693 * @endparblock
1694 */
1695rtems_status_code rtems_task_resume( rtems_id id );
1696
1697/* Generated from spec:/rtems/task/if/is-suspended */
1698
1699/**
1700 * @ingroup RTEMSAPIClassicTasks
1701 *
1702 * @brief Checks if the task is suspended.
1703 *
1704 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
1705 *   specify the calling task.
1706 *
1707 * This directive returns a status code indicating whether or not the task
1708 * specified by ``id`` is currently suspended.
1709 *
1710 * @retval ::RTEMS_SUCCESSFUL The task was **not** suspended.
1711 *
1712 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1713 *   specified by ``id``.
1714 *
1715 * @retval ::RTEMS_ALREADY_SUSPENDED The task was suspended.
1716 *
1717 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
1718 *
1719 * @par Constraints
1720 * @parblock
1721 * The following constraints apply to this directive:
1722 *
1723 * * The directive may be called from within interrupt context.
1724 *
1725 * * The directive may be called from within device driver initialization
1726 *   context.
1727 *
1728 * * The directive may be called from within task context.
1729 *
1730 * * The directive will not cause the calling task to be preempted.
1731 * @endparblock
1732 */
1733rtems_status_code rtems_task_is_suspended( rtems_id id );
1734
1735/* Generated from spec:/rtems/task/if/set-priority */
1736
1737/**
1738 * @ingroup RTEMSAPIClassicTasks
1739 *
1740 * @brief Sets the real priority or gets the current priority of the task.
1741 *
1742 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
1743 *   specify the calling task.
1744 *
1745 * @param new_priority is the new real priority or #RTEMS_CURRENT_PRIORITY to
1746 *   get the current priority.
1747 *
1748 * @param[out] old_priority is the pointer to an ::rtems_task_priority
1749 *   variable.  When the directive call is successful, the current or previous
1750 *   priority of the task with respect to its home scheduler will be stored in
1751 *   this variable.
1752 *
1753 * This directive manipulates the priority of the task specified by ``id``.
1754 * When ``new_priority`` is not equal to #RTEMS_CURRENT_PRIORITY, the specified
1755 * task's previous priority is returned in ``old_priority``.  When
1756 * ``new_priority`` is #RTEMS_CURRENT_PRIORITY, the specified task's current
1757 * priority is returned in ``old_priority``.
1758 *
1759 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1760 *
1761 * @retval ::RTEMS_INVALID_ADDRESS The ``old_priority`` parameter was NULL.
1762 *
1763 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1764 *   specified by ``id``.
1765 *
1766 * @retval ::RTEMS_INVALID_PRIORITY The task priority specified in
1767 *   ``new_priority`` was invalid with respect to the home scheduler of the
1768 *   task.
1769 *
1770 * @par Notes
1771 * @parblock
1772 * Valid priorities range from one to a maximum value which depends on the
1773 * configured scheduler.  The lower the priority value the higher is the
1774 * importance of the task.
1775 *
1776 * If the task is currently holding any binary semaphores which use a locking
1777 * protocol, then the task's priority cannot be lowered immediately.  If the
1778 * task's priority were lowered immediately, then this could violate properties
1779 * of the locking protocol and may result in priority inversion.  The requested
1780 * lowering of the task's priority will occur when the task has released all
1781 * binary semaphores which make the task more important.  The task's priority
1782 * can be increased regardless of the task's use of binary semaphores with
1783 * locking protocols.
1784 * @endparblock
1785 *
1786 * @par Constraints
1787 * @parblock
1788 * The following constraints apply to this directive:
1789 *
1790 * * The directive may be called from within interrupt context.
1791 *
1792 * * The directive may be called from within device driver initialization
1793 *   context.
1794 *
1795 * * The directive may be called from within task context.
1796 *
1797 * * The directive may change the priority of a task.  This may cause the
1798 *   calling task to be preempted.
1799 *
1800 * * When the directive operates on a remote object, the directive sends a
1801 *   message to the remote node and waits for a reply.  This will preempt the
1802 *   calling task.
1803 * @endparblock
1804 */
1805rtems_status_code rtems_task_set_priority(
1806  rtems_id             id,
1807  rtems_task_priority  new_priority,
1808  rtems_task_priority *old_priority
1809);
1810
1811/* Generated from spec:/rtems/task/if/get-priority */
1812
1813/**
1814 * @ingroup RTEMSAPIClassicTasks
1815 *
1816 * @brief Gets the current priority of the task with respect to the scheduler.
1817 *
1818 * @param task_id is the task identifier.  The constant #RTEMS_SELF may be used
1819 *   to specify the calling task.
1820 *
1821 * @param scheduler_id is the scheduler identifier.
1822 *
1823 * @param[out] priority is the pointer to an ::rtems_task_priority variable.
1824 *   When the directive call is successful, the current priority of the task
1825 *   with respect to the specified scheduler will be stored in this variable.
1826 *
1827 * This directive returns the current priority in ``priority`` of the task
1828 * specified by ``task_id`` with respect to the scheduler specified by
1829 * ``scheduler_id``.
1830 *
1831 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1832 *
1833 * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL.
1834 *
1835 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
1836 *   specified by ``task_id``.
1837 *
1838 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
1839 *   identifier specified by ``scheduler_id``.
1840 *
1841 * @retval ::RTEMS_NOT_DEFINED The task had no priority with respect to the
1842 *   scheduler.
1843 *
1844 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
1845 *
1846 * @par Notes
1847 * The current priority reflects temporary priority adjustments due to locking
1848 * protocols, the rate-monotonic period objects on some schedulers such as EDF,
1849 * and the POSIX sporadic server.
1850 *
1851 * @par Constraints
1852 * @parblock
1853 * The following constraints apply to this directive:
1854 *
1855 * * The directive may be called from within interrupt context.
1856 *
1857 * * The directive may be called from within device driver initialization
1858 *   context.
1859 *
1860 * * The directive may be called from within task context.
1861 *
1862 * * The directive will not cause the calling task to be preempted.
1863 * @endparblock
1864 */
1865rtems_status_code rtems_task_get_priority(
1866  rtems_id             task_id,
1867  rtems_id             scheduler_id,
1868  rtems_task_priority *priority
1869);
1870
1871/* Generated from spec:/rtems/task/if/mode */
1872
1873/**
1874 * @ingroup RTEMSAPIClassicTasks
1875 *
1876 * @brief Gets and optionally sets the mode of the calling task.
1877 *
1878 * @param mode_set is the mode set to apply to the calling task.  When ``mask``
1879 *   is set to #RTEMS_CURRENT_MODE, the value of this parameter is ignored.
1880 *   Only modes requested by ``mask`` are applied to the calling task.
1881 *
1882 * @param mask is the mode mask which specifies which modes in ``mode_set`` are
1883 *   applied to the calling task.  When the value is #RTEMS_CURRENT_MODE, the
1884 *   mode of the calling task is not changed.
1885 *
1886 * @param previous_mode_set is the pointer to a mode variable.  When the
1887 *   directive call is successful, the mode of the task before any mode changes
1888 *   done by the directive call will be stored in this variable.
1889 *
1890 * This directive queries and optionally manipulates the execution mode of the
1891 * calling task.  A task's execution mode enables and disables preemption,
1892 * timeslicing, asynchronous signal processing, as well as specifying the
1893 * interrupt level.  To modify an execution mode, the mode class(es) to be
1894 * changed must be specified in the ``mask`` parameter and the desired mode(s)
1895 * must be specified in the ``mode_set`` parameter.
1896 *
1897 * A task can obtain its current execution mode, without modifying it, by
1898 * calling this directive with a ``mask`` value of #RTEMS_CURRENT_MODE.
1899 *
1900 * The **mode set** specified in ``mode_set`` is built through a *bitwise or*
1901 * of the mode constants described below.  Not all combinations of modes are
1902 * allowed.  Some modes are mutually exclusive.  If mutually exclusive modes
1903 * are combined, the behaviour is undefined.  Default task modes can be
1904 * selected by using the #RTEMS_DEFAULT_MODES constant.  The task mode set
1905 * defines
1906 *
1907 * * the preemption mode of the task: #RTEMS_PREEMPT (default) or
1908 *   #RTEMS_NO_PREEMPT,
1909 *
1910 * * the timeslicing mode of the task: #RTEMS_TIMESLICE or #RTEMS_NO_TIMESLICE
1911 *   (default),
1912 *
1913 * * the ASR processing mode of the task: #RTEMS_ASR (default) or
1914 *   #RTEMS_NO_ASR,
1915 *
1916 * * the interrupt level of the task: RTEMS_INTERRUPT_LEVEL() with a default of
1917 *   ``RTEMS_INTERRUPT_LEVEL( 0 )`` which is associated with enabled
1918 *   interrupts.
1919 *
1920 * The **mode mask** specified in ``mask`` is built through a *bitwise or* of
1921 * the mode mask constants described below.
1922 *
1923 * When the #RTEMS_PREEMPT_MASK is set in ``mask``, the **preemption mode** of
1924 * the calling task is
1925 *
1926 * * enabled by using the #RTEMS_PREEMPT mode constant in ``mode_set`` and
1927 *
1928 * * disabled by using the #RTEMS_NO_PREEMPT mode constant in ``mode_set``.
1929 *
1930 * When the #RTEMS_TIMESLICE_MASK is set in ``mask``, the **timeslicing mode**
1931 * of the calling task is
1932 *
1933 * * enabled by using the #RTEMS_TIMESLICE mode constant in ``mode_set`` and
1934 *
1935 * * disabled by using the #RTEMS_NO_TIMESLICE mode constant in ``mode_set``.
1936 *
1937 * Enabling timeslicing has no effect if preemption is disabled.  For a task to
1938 * be timesliced, that task must have both preemption and timeslicing enabled.
1939 *
1940 * When the #RTEMS_ASR_MASK is set in ``mask``, the **ASR processing mode** of
1941 * the calling task is
1942 *
1943 * * enabled by using the #RTEMS_ASR mode constant in ``mode_set`` and
1944 *
1945 * * disabled by using the #RTEMS_NO_ASR mode constant in ``mode_set``.
1946 *
1947 * When the #RTEMS_INTERRUPT_MASK is set in ``mask``, **interrupts** of the
1948 * calling task are
1949 *
1950 * * enabled by using the RTEMS_INTERRUPT_LEVEL() mode macro with a value of
1951 *   zero (0) in ``mode_set`` and
1952 *
1953 * * disabled up to the specified level by using the RTEMS_INTERRUPT_LEVEL()
1954 *   mode macro with a positive value in ``mode_set``.
1955 *
1956 * An interrupt level of zero is associated with enabled interrupts on all
1957 * target processors.  The interrupt level portion of the task mode supports a
1958 * maximum of 256 interrupt levels.  These levels are mapped onto the interrupt
1959 * levels actually supported by the target processor in a processor dependent
1960 * fashion.
1961 *
1962 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
1963 *
1964 * @retval ::RTEMS_NOT_IMPLEMENTED The #RTEMS_NO_PREEMPT was set in
1965 *   ``mode_set`` and setting the preemption mode was requested by
1966 *   #RTEMS_PREEMPT_MASK in ``mask`` and the system configuration had no
1967 *   implementation for this mode.
1968 *
1969 * @retval ::RTEMS_NOT_IMPLEMENTED The RTEMS_INTERRUPT_LEVEL() was set to a
1970 *   positive level in ``mode_set`` and setting the interrupt level was
1971 *   requested by #RTEMS_INTERRUPT_MASK in ``mask`` and the system
1972 *   configuration had no implementation for this mode.
1973 *
1974 * @par Constraints
1975 * @parblock
1976 * The following constraints apply to this directive:
1977 *
1978 * * The directive may be called from within task context.
1979 *
1980 * * When the directive enables preemption for the calling task, another task
1981 *   may preempt the calling task.
1982 *
1983 * * While thread dispatching is disabled, if the directive performs a thread
1984 *   dispatch, then the fatal error with the fatal source INTERNAL_ERROR_CORE
1985 *   and the fatal code INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will
1986 *   occur.
1987 * @endparblock
1988 */
1989rtems_status_code rtems_task_mode(
1990  rtems_mode  mode_set,
1991  rtems_mode  mask,
1992  rtems_mode *previous_mode_set
1993);
1994
1995/* Generated from spec:/rtems/task/if/wake-after */
1996
1997/**
1998 * @ingroup RTEMSAPIClassicTasks
1999 *
2000 * @brief Wakes up after an interval in clock ticks or yields the processor.
2001 *
2002 * @param ticks is the interval in clock ticks to delay the task or
2003 *   #RTEMS_YIELD_PROCESSOR to yield the processor.
2004 *
2005 * This directive blocks the calling task for the specified ``ticks`` of clock
2006 * ticks if the value is not equal to #RTEMS_YIELD_PROCESSOR.  When the
2007 * requested interval has elapsed, the task is made ready.  The clock tick
2008 * directives automatically updates the delay period.  The calling task may
2009 * give up the processor and remain in the ready state by specifying a value of
2010 * #RTEMS_YIELD_PROCESSOR in ``ticks``.
2011 *
2012 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
2013 *
2014 * @par Notes
2015 * Setting the system date and time with the rtems_clock_set() directive and
2016 * similar directives which set CLOCK_REALTIME have no effect on a
2017 * rtems_task_wake_after() blocked task.
2018 *
2019 * @par Constraints
2020 * @parblock
2021 * The following constraints apply to this directive:
2022 *
2023 * * The directive may be called from within task context.
2024 *
2025 * * The directive requires a Clock Driver.
2026 *
2027 * * While thread dispatching is disabled, if the directive performs a thread
2028 *   dispatch, then the fatal error with the fatal source INTERNAL_ERROR_CORE
2029 *   and the fatal code INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will
2030 *   occur.
2031 * @endparblock
2032 */
2033rtems_status_code rtems_task_wake_after( rtems_interval ticks );
2034
2035/* Generated from spec:/rtems/task/if/wake-when */
2036
2037/**
2038 * @ingroup RTEMSAPIClassicTasks
2039 *
2040 * @brief Wakes up when specified.
2041 *
2042 * @param time_buffer is the date and time to wake up.
2043 *
2044 * This directive blocks a task until the date and time specified in
2045 * ``time_buffer``.  At the requested date and time, the calling task will be
2046 * unblocked and made ready to execute.
2047 *
2048 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
2049 *
2050 * @retval ::RTEMS_NOT_DEFINED The system date and time was not set.
2051 *
2052 * @retval ::RTEMS_INVALID_ADDRESS The ``time_buffer`` parameter was NULL.
2053 *
2054 * @retval ::RTEMS_INVALID_CLOCK The time of day was invalid.
2055 *
2056 * @par Notes
2057 * The ticks portion of ``time_buffer`` structure is ignored.  The timing
2058 * granularity of this directive is a second.
2059 *
2060 * @par Constraints
2061 * @parblock
2062 * The following constraints apply to this directive:
2063 *
2064 * * The directive may be called from within task context.
2065 *
2066 * * The directive requires a Clock Driver.
2067 *
2068 * * While thread dispatching is disabled, if the directive performs a thread
2069 *   dispatch, then the fatal error with the fatal source INTERNAL_ERROR_CORE
2070 *   and the fatal code INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will
2071 *   occur.
2072 * @endparblock
2073 */
2074rtems_status_code rtems_task_wake_when( rtems_time_of_day *time_buffer );
2075
2076/* Generated from spec:/rtems/task/if/get-scheduler */
2077
2078/**
2079 * @ingroup RTEMSAPIClassicTasks
2080 *
2081 * @brief Gets the home scheduler of the task.
2082 *
2083 * @param task_id is the task identifier.  The constant #RTEMS_SELF may be used
2084 *   to specify the calling task.
2085 *
2086 * @param[out] scheduler_id is the pointer to an ::rtems_id variable.  When the
2087 *   directive call is successful, the identifier of the home scheduler of the
2088 *   task will be stored in this variable.
2089 *
2090 * This directive returns the identifier of the home scheduler of the task
2091 * specified by ``task_id`` in ``scheduler_id``.
2092 *
2093 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
2094 *
2095 * @retval ::RTEMS_INVALID_ADDRESS The ``scheduler_id`` parameter was NULL.
2096 *
2097 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
2098 *   specified by ``task_id``.
2099 *
2100 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
2101 *
2102 * @par Constraints
2103 * @parblock
2104 * The following constraints apply to this directive:
2105 *
2106 * * The directive may be called from within interrupt context.
2107 *
2108 * * The directive may be called from within device driver initialization
2109 *   context.
2110 *
2111 * * The directive may be called from within task context.
2112 *
2113 * * The directive will not cause the calling task to be preempted.
2114 * @endparblock
2115 */
2116rtems_status_code rtems_task_get_scheduler(
2117  rtems_id  task_id,
2118  rtems_id *scheduler_id
2119);
2120
2121/* Generated from spec:/rtems/task/if/set-scheduler */
2122
2123/**
2124 * @ingroup RTEMSAPIClassicTasks
2125 *
2126 * @brief Sets the home scheduler for the task.
2127 *
2128 * @param task_id is the task identifier.  The constant #RTEMS_SELF may be used
2129 *   to specify the calling task.
2130 *
2131 * @param scheduler_id is the scheduler identifier of the new home scheduler
2132 *   for the task specified by ``task_id``.
2133 *
2134 * @param priority is the new real priority for the task with respect to the
2135 *   scheduler specified by ``scheduler_id``.
2136 *
2137 * This directive sets the home scheduler to the scheduler specified by
2138 * ``scheduler_id`` for the task specified by ``task_id``.
2139 *
2140 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
2141 *
2142 * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the
2143 *   identifier specified by ``scheduler_id``.
2144 *
2145 * @retval ::RTEMS_INVALID_PRIORITY There task priority specified in
2146 *   ``priority`` was invalid with respect to the scheduler specified by
2147 *   ``scheduler_id``.
2148 *
2149 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
2150 *   specified by ``task_id``.
2151 *
2152 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
2153 *
2154 * @par Constraints
2155 * @parblock
2156 * The following constraints apply to this directive:
2157 *
2158 * * The directive may be called from within interrupt context.
2159 *
2160 * * The directive may be called from within device driver initialization
2161 *   context.
2162 *
2163 * * The directive may be called from within task context.
2164 *
2165 * * The directive may change the priority of a task.  This may cause the
2166 *   calling task to be preempted.
2167 * @endparblock
2168 */
2169rtems_status_code rtems_task_set_scheduler(
2170  rtems_id            task_id,
2171  rtems_id            scheduler_id,
2172  rtems_task_priority priority
2173);
2174
2175/* Generated from spec:/rtems/task/if/get-affinity */
2176
2177/**
2178 * @ingroup RTEMSAPIClassicTasks
2179 *
2180 * @brief Gets the processor affinity of the task.
2181 *
2182 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
2183 *   specify the calling task.
2184 *
2185 * @param cpusetsize is the size of the referenced processor set variable in
2186 *   bytes.
2187 *
2188 * @param[out] cpuset is the pointer to a processor set variable.  When the
2189 *   directive call is successful, the processor affinity set of the task will
2190 *   be stored in this variable.  A set bit in the processor set means that the
2191 *   corresponding processor is in the processor affinity set of the task,
2192 *   otherwise the bit is cleared.
2193 *
2194 * This directive returns the processor affinity of the task in ``cpuset`` of
2195 * the task specified by ``id``.
2196 *
2197 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
2198 *
2199 * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL.
2200 *
2201 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
2202 *   specified by ``id``.
2203 *
2204 * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for
2205 *   the processor affinity set of the task.
2206 *
2207 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
2208 *
2209 * @par Constraints
2210 * @parblock
2211 * The following constraints apply to this directive:
2212 *
2213 * * The directive may be called from within interrupt context.
2214 *
2215 * * The directive may be called from within device driver initialization
2216 *   context.
2217 *
2218 * * The directive may be called from within task context.
2219 *
2220 * * The directive will not cause the calling task to be preempted.
2221 * @endparblock
2222 */
2223rtems_status_code rtems_task_get_affinity(
2224  rtems_id   id,
2225  size_t     cpusetsize,
2226  cpu_set_t *cpuset
2227);
2228
2229/* Generated from spec:/rtems/task/if/set-affinity */
2230
2231/**
2232 * @ingroup RTEMSAPIClassicTasks
2233 *
2234 * @brief Sets the processor affinity of the task.
2235 *
2236 * @param id is the task identifier.  The constant #RTEMS_SELF may be used to
2237 *   specify the calling task.
2238 *
2239 * @param cpusetsize is the size of the referenced processor set variable in
2240 *   bytes.
2241 *
2242 * @param cpuset is the pointer to a processor set variable.  The processor set
2243 *   defines the new processor affinity set of the task.  A set bit in the
2244 *   processor set means that the corresponding processor shall be in the
2245 *   processor affinity set of the task, otherwise the bit shall be cleared.
2246 *
2247 * This directive sets the processor affinity of the task specified by ``id``.
2248 *
2249 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
2250 *
2251 * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL.
2252 *
2253 * @retval ::RTEMS_INVALID_ID There was no task associated with the identifier
2254 *   specified by ``id``.
2255 *
2256 * @retval ::RTEMS_INVALID_NUMBER The referenced processor set was not a valid
2257 *   new processor affinity set for the task.
2258 *
2259 * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node.
2260 *
2261 * @par Constraints
2262 * @parblock
2263 * The following constraints apply to this directive:
2264 *
2265 * * The directive may be called from within interrupt context.
2266 *
2267 * * The directive may be called from within device driver initialization
2268 *   context.
2269 *
2270 * * The directive may be called from within task context.
2271 *
2272 * * The directive may change the processor affinity of a task.  This may cause
2273 *   the calling task to be preempted.
2274 * @endparblock
2275 */
2276rtems_status_code rtems_task_set_affinity(
2277  rtems_id         id,
2278  size_t           cpusetsize,
2279  const cpu_set_t *cpuset
2280);
2281
2282/* Generated from spec:/rtems/task/if/iterate */
2283
2284/**
2285 * @ingroup RTEMSAPIClassicTasks
2286 *
2287 * @brief Iterates over all tasks and invokes the visitor routine for each
2288 *   task.
2289 *
2290 * @param visitor is the visitor routine invoked for each task.
2291 *
2292 * @param arg is the argument passed to each visitor routine invocation during
2293 *   the iteration.
2294 *
2295 * This directive iterates over all tasks in the system.  This operation covers
2296 * all tasks of all APIs.  The user should be careful in accessing the contents
2297 * of the TCB.  The visitor argument ``arg`` is passed to all invocations of
2298 * ``visitor`` in addition to the TCB. The iteration stops immediately in case
2299 * the visitor routine returns true.
2300 *
2301 * @par Notes
2302 * The visitor routine is invoked while owning the objects allocator lock.  It
2303 * is allowed to perform blocking operations in the visitor routine, however,
2304 * care must be taken so that no deadlocks via the object allocator lock can
2305 * occur.
2306 *
2307 * @par Constraints
2308 * @parblock
2309 * The following constraints apply to this directive:
2310 *
2311 * * The directive may be called from within device driver initialization
2312 *   context.
2313 *
2314 * * The directive may be called from within task context.
2315 *
2316 * * The directive may obtain and release the object allocator mutex.  This may
2317 *   cause the calling task to be preempted.
2318 * @endparblock
2319 */
2320void rtems_task_iterate( rtems_task_visitor visitor, void *arg );
2321
2322#ifdef __cplusplus
2323}
2324#endif
2325
2326#endif /* _RTEMS_RTEMS_TASKS_H */
Note: See TracBrowser for help on using the repository browser.