RTEMS
|
The Task Manager provides a comprehensive set of directives to create, delete, and administer tasks. More...
Files | |
file | tasks.h |
This header file defines the main parts of the Tasks Manager API. | |
Classes | |
struct | rtems_task_config |
This structure defines the configuration of a task constructed by rtems_task_construct(). More... | |
struct | rtems_initialization_tasks_table |
% More... | |
Macros | |
#define | RTEMS_CURRENT_PRIORITY 0 |
This constant is passed to {set-priority:/name}() when the caller wants to obtain the current priority. | |
#define | rtems_scheduler_get_processor() _SMP_Get_current_processor() |
Returns the index of the current processor. More... | |
#define | rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum() |
Returns the processor maximum supported by the system. More... | |
#define | RTEMS_CONFIGURED_MINIMUM_STACK_SIZE 0 |
% | |
#define | RTEMS_MAXIMUM_PRIORITY _RTEMS_Maximum_priority() |
% | |
#define | RTEMS_MINIMUM_PRIORITY 1 |
% | |
#define | RTEMS_MINIMUM_STACK_SIZE STACK_MINIMUM_SIZE |
% | |
#define | RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY |
% | |
#define | RTEMS_SELF OBJECTS_ID_OF_SELF |
% | |
#define | RTEMS_TASK_STORAGE_ALIGNMENT CPU_HEAP_ALIGNMENT |
This constant defines the recommended alignment of a task storage area in bytes. More... | |
#define | RTEMS_TASK_STORAGE_SIZE(_size, _attributes) |
Returns the recommended task storage area size for the specified size and task attributes. More... | |
#define | RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT |
% | |
Typedefs | |
typedef uint32_t | rtems_task_priority |
% | |
typedef void | rtems_task |
% | |
typedef CPU_Uint32ptr | rtems_task_argument |
This type is used to represent task argument values. More... | |
typedef struct _Thread_Control | rtems_tcb |
% | |
typedef rtems_task(* | rtems_task_entry) (rtems_task_argument) |
This type defines the entry point of an RTEMS task. | |
typedef bool(* | rtems_task_visitor) (rtems_tcb *, void *) |
% | |
The Task Manager provides a comprehensive set of directives to create, delete, and administer tasks.
#define rtems_scheduler_get_processor | ( | ) | _SMP_Get_current_processor() |
Returns the index of the current processor.
In uniprocessor configurations, this macro evaluates to a compile time constant of zero.
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 rtems_scheduler_get_processor_maximum() 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.
#define rtems_scheduler_get_processor_maximum | ( | ) | _SMP_Get_processor_maximum() |
Returns the processor maximum supported by the system.
In uniprocessor configurations, this macro evaluates to a compile time constant of one.
In SMP configurations, this macro 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 may be online (online processors have a scheduler assigned).
#define RTEMS_TASK_STORAGE_ALIGNMENT CPU_HEAP_ALIGNMENT |
This constant defines the recommended alignment of a task storage area in bytes.
Use it with RTEMS_ALIGNED() to define the alignment of a statically allocated task storage area.
#define RTEMS_TASK_STORAGE_SIZE | ( | _size, | |
_attributes | |||
) |
Returns the recommended task storage area size for the specified size and task attributes.
_size | is the size dedicated to the task stack and thread-local storage in bytes. |
_attributes | is the attribute set of the task using the storage area. |
typedef CPU_Uint32ptr rtems_task_argument |
rtems_status_code rtems_scheduler_add_processor | ( | rtems_id | scheduler_id, |
uint32_t | cpu_index | ||
) |
Adds the processor to the set of processors owned by the scheduler instance.
This directive shall be called from task context. It obtains and releases the objects allocator lock.
scheduler_id | is the scheduler instance identifier. |
cpu_index | is the index of the processor to add. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INCORRECT_STATE | The processor was configured to be used by the application, however, it was not online. |
RTEMS_INVALID_ID | The scheduler instance identifier was invalid. |
RTEMS_NOT_CONFIGURED | The processor was not configured to be used by the application. |
RTEMS_RESOURCE_IN_USE | The processor was already assigned to a scheduler instance. |
Definition at line 24 of file scheduleraddprocessor.c.
rtems_status_code rtems_scheduler_get_maximum_priority | ( | rtems_id | scheduler_id, |
rtems_task_priority * | priority | ||
) |
Gets the maximum task priority of the scheduler instance.
scheduler_id | is the scheduler instance identifier. | |
[out] | priority | is the pointer to a task priority variable. The maximum priority of the scheduler instance will be stored in this variable, if the operation is successful. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The priority parameter was NULL. |
RTEMS_INVALID_ID | The scheduler instance identifier was invalid. |
rtems_status_code rtems_scheduler_get_processor_set | ( | rtems_id | scheduler_id, |
size_t | cpusetsize, | ||
cpu_set_t * | cpuset | ||
) |
Gets the set of processors owned by the scheduler instance.
scheduler_id | is the scheduler instance identifier. | |
cpusetsize | is the size of the referenced processor set variable in bytes. This value shall be positive. | |
[out] | cpuset | is the pointer to a processor set variable. The processor set of the scheduler instance will be stored in this variable, in case of a successful operation. A set bit in the processor set means that the corresponding processor is owned by the scheduler instance, otherwise the bit is cleared. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The cpuset parameter was NULL. |
RTEMS_INVALID_ID | The scheduler instance identifier was invalid. |
RTEMS_INVALID_NUMBER | The provided processor set was too small for the set of processors owned by the scheduler instance. |
Definition at line 22 of file schedulergetprocessorset.c.
rtems_status_code rtems_scheduler_ident | ( | rtems_name | name, |
rtems_id * | id | ||
) |
Identifies a scheduler instance by its name.
The scheduler name is determined by the scheduler configuration.
name | is the scheduler name. | |
[out] | id | is the pointer to an object identifier variable. The identifier of the scheduler instance will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The id parameter was NULL. |
RTEMS_INVALID_NAME | The scheduler name was invalid. |
Definition at line 22 of file schedulerident.c.
rtems_status_code rtems_scheduler_ident_by_processor | ( | uint32_t | cpu_index, |
rtems_id * | id | ||
) |
Identifies a scheduler instance by a processor index.
cpu_index | is the processor index to identify the scheduler instance. | |
[out] | id | is the pointer to an object identifier variable. The identifier of the scheduler instance will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INCORRECT_STATE | The processor index was valid, however, the corresponding processor was not owned by a scheduler instance. |
RTEMS_INVALID_ADDRESS | The id parameter was NULL. |
RTEMS_INVALID_NAME | The processor index was invalid. |
Definition at line 23 of file scheduleridentbyprocessor.c.
rtems_status_code rtems_scheduler_ident_by_processor_set | ( | size_t | cpusetsize, |
const cpu_set_t * | cpuset, | ||
rtems_id * | id | ||
) |
Identifies a scheduler instance by a processor set.
The scheduler instance is selected according to the highest numbered online processor in the specified processor set.
cpusetsize | is the size of the referenced processor set variable in bytes. This value shall be positive. | |
cpuset | is the pointer to a processor set variable. The referenced processor set will be used to identify the scheduler instance. | |
[out] | id | is the pointer to an object identifier variable. The identifier of the scheduler instance will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INCORRECT_STATE | The processor set was valid, however, the highest numbered online processor in the processor set was not owned by a scheduler instance. |
RTEMS_INVALID_ADDRESS | The id parameter was NULL. |
RTEMS_INVALID_NAME | The processor set contained no online processor. |
RTEMS_INVALID_SIZE | The processor set size was invalid. |
Definition at line 23 of file scheduleridentbyprocessorset.c.
rtems_status_code rtems_scheduler_map_priority_from_posix | ( | rtems_id | scheduler_id, |
int | posix_priority, | ||
rtems_task_priority * | priority | ||
) |
Maps a POSIX thread priority to the corresponding Classic API task priority.
scheduler_id | is the scheduler instance identifier. | |
posix_priority | is the POSIX thread priority to map. | |
[out] | priority | is the pointer to a Classic API task priority variable. The Classic API task priority value corresponding to the specified POSIX thread priority value will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The priority parameter was NULL. |
RTEMS_INVALID_ID | The scheduler instance identifier was invalid. |
RTEMS_INVALID_PRIORITY | The POSIX thread priority was invalid. |
rtems_status_code rtems_scheduler_map_priority_to_posix | ( | rtems_id | scheduler_id, |
rtems_task_priority | priority, | ||
int * | posix_priority | ||
) |
Maps a Classic API task priority to the corresponding POSIX thread priority.
scheduler_id | is the scheduler instance identifier. | |
priority | is the Classic API task priority to map. | |
[out] | posix_priority | is the pointer to a POSIX thread priority variable. The POSIX thread priority value corresponding to the specified Classic API task priority value will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The posix_priority parameter was NULL. |
RTEMS_INVALID_ID | The scheduler instance identifier was invalid. |
RTEMS_INVALID_PRIORITY | The Classic API task priority was invalid. |
rtems_status_code rtems_scheduler_remove_processor | ( | rtems_id | scheduler_id, |
uint32_t | cpu_index | ||
) |
Removes a processor from set of processors owned by the scheduler instance.
This directive shall be called from task context. It obtains and releases the objects allocator lock. Removing a processor from a scheduler instance is a complex operation that involves all tasks of the system.
scheduler_id | is the scheduler instance identifier. |
cpu_index | is the index of the processor to remove. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ID | The scheduler instance identifier was invalid. |
RTEMS_INVALID_NUMBER | The processor was not owned by the specified scheduler instance. |
RTEMS_RESOURCE_IN_USE | The set of processors owned by the specified scheduler instance would have been empty after the processor removal and there was at least one non-idle task that used this scheduler instance as its home scheduler instance. |
Definition at line 64 of file schedulerremoveprocessor.c.
rtems_status_code rtems_task_construct | ( | const rtems_task_config * | config, |
rtems_id * | id | ||
) |
Constructs a task from the specified the task configuration.
In contrast to tasks created by rtems_task_create(), the tasks constructed by this directive use a user-provided task storage area. The task storage area contains the task stack, the thread-local storage, and the floating-point context on architectures with a separate floating-point context.
This directive is intended for applications which do not want to use the RTEMS Workspace and instead statically allocate all operating system resources. It is not recommended to use rtems_task_create() and rtems_task_construct() together in an application. It is also not recommended to use rtems_task_construct() for drivers or general purpose libraries. The reason for these recommendations is that the task configuration needs settings which can be only given with a through knowledge of the application resources.
An application based solely on static allocation can avoid any runtime memory allocators. This can simplify the application architecture as well as any analysis that may be required.
The stack space estimate done by <rtems/confdefs.h> assumes that all tasks are created by rtems_task_create(). The estimate can be adjusted to take user-provided task storage areas into account through the CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE application configuration option.
The CONFIGURE_MAXIMUM_TASKS should include tasks constructed by rtems_task_construct().
config | is the task configuration. | |
[out] | id | is the pointer to an object identifier variable. The identifier of the constructed task object will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The id parameter was NULL. |
RTEMS_INVALID_NAME | The task name was invalid. |
RTEMS_INVALID_PRIORITY | The initial task priority was invalid. |
RTEMS_INVALID_SIZE | The thread-local storage size is greater than the maximum thread-local storage size specified in the task configuration. The thread-local storage size is determined by the thread-local variables used by the application and CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE. |
RTEMS_INVALID_SIZE | The task storage area was too small to provide a task stack of the configured minimum size, see CONFIGURE_MINIMUM_TASK_STACK_SIZE. The task storage area contains the task stack, the thread-local storage, and the floating-point context on architectures with a separate floating-point context. |
RTEMS_TOO_MANY | There was no inactive task object available to construct a task. |
RTEMS_TOO_MANY | In multiprocessing configurations, there was no inactive global object available to construct a global task. |
RTEMS_UNSATISFIED | One of the task create extensions failed during the task construction. |
RTEMS_UNSATISFIED | In SMP configurations, the non-preemption mode was not supported. |
RTEMS_UNSATISFIED | In SMP configurations, the interrupt level mode was not supported. |
Definition at line 73 of file taskconstruct.c.
rtems_status_code rtems_task_create | ( | rtems_name | name, |
rtems_task_priority | initial_priority, | ||
size_t | stack_size, | ||
rtems_mode | initial_modes, | ||
rtems_attribute | attribute_set, | ||
rtems_id * | id | ||
) |
Creates a task object.
This directive creates a task which resides on the local node. It allocates and initializes a TCB, a stack, and an optional floating point context area. The mode parameter contains values which sets the task’s initial execution mode. The RTEMS_FLOATING_POINT attribute should be specified if the created task is to use a numeric coprocessor. For performance reasons, it is recommended that tasks not using the numeric coprocessor should specify the RTEMS_NO_FLOATING_POINT attribute. If the RTEMS_GLOBAL attribute is specified, the task can be accessed from remote nodes. The task id, returned in id, is used in other task related directives to access the task. When created, a task is placed in the dormant state and can only be made ready to execute using the directive rtems_task_start().
name | is the user-defined task name. | |
initial_priority | is the initial task priority. | |
stack_size | is the task stack size in bytes. | |
initial_modes | is the initial task mode. | |
attribute_set | is the task attribute set. | |
[out] | id | is the pointer to an object identifier variable. The object identifier of the new task will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The id parameter was NULL. |
RTEMS_INVALID_NAME | The task name was invalid. |
RTEMS_INVALID_PRIORITY | The initial task priority was invalid. |
RTEMS_MP_NOT_CONFIGURED | The multiprocessing support was not configured. |
RTEMS_TOO_MANY | There was no inactive task object available to create a new task. |
RTEMS_TOO_MANY | In multiprocessing configurations, there was no inactive global object available to create a new global task. |
RTEMS_UNSATISFIED | There was not enough memory to allocate the task storage area. The task storage area contains the task stack, the thread-local storage, and the floating point context. |
RTEMS_UNSATISFIED | One of the task create extensions failed to create the new task. |
RTEMS_UNSATISFIED | In SMP configurations, the non-preemption mode was not supported. |
RTEMS_UNSATISFIED | In SMP configurations, the interrupt level mode was not supported. |
rtems_status_code rtems_task_delete | ( | rtems_id | id | ) |
rtems_status_code rtems_task_get_affinity | ( | rtems_id | id, |
size_t | cpusetsize, | ||
cpu_set_t * | cpuset | ||
) |
rtems_status_code rtems_task_get_priority | ( | rtems_id | task_id, |
rtems_id | scheduler_id, | ||
rtems_task_priority * | priority | ||
) |
rtems_status_code rtems_task_get_scheduler | ( | rtems_id | task_id, |
rtems_id * | scheduler_id | ||
) |
rtems_status_code rtems_task_ident | ( | rtems_name | name, |
uint32_t | node, | ||
rtems_id * | id | ||
) |
Identifies a task object by the specified object name.
This directive obtains the task identifier associated with the task name specified in name
.
A task may obtain its own identifier by specifying RTEMS_SELF for the name.
The node to search is specified in node
. It shall be
If the task name is not unique, then the task identifier will match the first task with that name in the search order. However, this task identifier is not guaranteed to correspond to the desired task. The task identifier is used with other task related directives to access the task.
If node is RTEMS_SEARCH_ALL_NODES, all nodes are searched with the local node being searched first. All other nodes are searched with the lowest numbered node searched first.
If node is a valid node number which does not represent the local node, then only the tasks exported by the designated node are searched.
This directive does not generate activity on remote nodes. It accesses only the local copy of the global object table.
name | is the object name to look up. | |
node | is the node or node set to search for a matching object. | |
[out] | id | is the pointer to an object identifier variable. The object identifier of an object with the specified name will be stored in this variable, in case of a successful operation. |
RTEMS_SUCCESSFUL | The requested operation was successful. |
RTEMS_INVALID_ADDRESS | The id parameter was NULL. |
RTEMS_INVALID_NAME | There was no object with the specified name on the specified nodes. |
RTEMS_INVALID_NODE | In multiprocessing configurations, the specified node was invalid. |
Definition at line 45 of file taskident.c.
rtems_status_code rtems_task_is_suspended | ( | rtems_id | id | ) |
void rtems_task_iterate | ( | rtems_task_visitor | visitor, |
void * | arg | ||
) |
%
visitor | % |
arg | % |
rtems_status_code rtems_task_mode | ( | rtems_mode | mode_set, |
rtems_mode | mask, | ||
rtems_mode * | previous_mode_set | ||
) |
%
mode_set | % |
mask | % |
previous_mode_set | % |
rtems_status_code rtems_task_restart | ( | rtems_id | id, |
rtems_task_argument | argument | ||
) |
rtems_status_code rtems_task_resume | ( | rtems_id | id | ) |
rtems_status_code rtems_task_set_affinity | ( | rtems_id | id, |
size_t | cpusetsize, | ||
const cpu_set_t * | cpuset | ||
) |
rtems_status_code rtems_task_set_priority | ( | rtems_id | id, |
rtems_task_priority | new_priority, | ||
rtems_task_priority * | old_priority | ||
) |
rtems_status_code rtems_task_set_scheduler | ( | rtems_id | task_id, |
rtems_id | scheduler_id, | ||
rtems_task_priority | priority | ||
) |
rtems_status_code rtems_task_start | ( | rtems_id | id, |
rtems_task_entry | entry_point, | ||
rtems_task_argument | argument | ||
) |
rtems_status_code rtems_task_suspend | ( | rtems_id | id | ) |
rtems_status_code rtems_task_wake_after | ( | rtems_interval | ticks | ) |
rtems_status_code rtems_task_wake_when | ( | rtems_time_of_day * | time_buffer | ) |
%
time_buffer | % |