5.5. Directives

This section details the directives of the Scheduler Manager. A subsection is dedicated to each of this manager’s directives and lists the calling sequence, parameters, description, return values, and notes of the directive.

5.5.1. rtems_scheduler_ident()

Identifies a scheduler by the object name.

CALLING SEQUENCE:

rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id );

PARAMETERS:

name

This parameter is the scheduler name to look up.

id

This parameter is the pointer to an rtems_id object. When the directive call is successful, the identifier of the scheduler will be stored in this object.

DESCRIPTION:

This directive obtains a scheduler identifier associated with the scheduler name specified in name.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_NAME

There was no scheduler associated with the name.

RTEMS_INVALID_ADDRESS

The id parameter was NULL.

NOTES:

The scheduler name is determined by the scheduler configuration.

The scheduler identifier is used with other scheduler related directives to access the scheduler.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.2. rtems_scheduler_ident_by_processor()

Identifies a scheduler by the processor index.

CALLING SEQUENCE:

rtems_status_code rtems_scheduler_ident_by_processor(
  uint32_t  cpu_index,
  rtems_id *id
);

PARAMETERS:

cpu_index

This parameter is the processor index to identify the scheduler.

id

This parameter is the pointer to an rtems_id object. When the directive call is successful, the identifier of the scheduler will be stored in this object.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ADDRESS

The id parameter was NULL.

RTEMS_INVALID_NAME

The processor index was invalid.

RTEMS_INCORRECT_STATE

The processor index was valid, however, the corresponding processor was not owned by a scheduler.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.3. rtems_scheduler_ident_by_processor_set()

Identifies a scheduler by the processor set.

CALLING SEQUENCE:

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

PARAMETERS:

cpusetsize

This parameter is the size of the processor set referenced by cpuset in bytes. The size shall be positive.

cpuset

This parameter is the pointer to a cpu_set_t. The referenced processor set will be used to identify the scheduler.

id

This parameter is the pointer to an rtems_id object. When the directive call is successful, the identifier of the scheduler will be stored in this object.

DESCRIPTION:

The scheduler is selected according to the highest numbered online processor in the specified processor set.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ADDRESS

The id parameter was NULL.

RTEMS_INVALID_ADDRESS

The cpuset parameter was NULL.

RTEMS_INVALID_SIZE

The processor set size was invalid.

RTEMS_INVALID_NAME

The processor set contained no online processor.

RTEMS_INCORRECT_STATE

The processor set was valid, however, the highest numbered online processor in the processor set was not owned by a scheduler.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.4. rtems_scheduler_get_maximum_priority()

Gets the maximum task priority of the scheduler.

CALLING SEQUENCE:

rtems_status_code rtems_scheduler_get_maximum_priority(
  rtems_id             scheduler_id,
  rtems_task_priority *priority
);

PARAMETERS:

scheduler_id

This parameter is the scheduler identifier.

priority

This parameter is the pointer to an rtems_task_priority object. When the directive the maximum priority of the scheduler will be stored in this object.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ID

There was no scheduler associated with the identifier specified by scheduler_id.

RTEMS_INVALID_ADDRESS

The priority parameter was NULL.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.5. rtems_scheduler_map_priority_to_posix()

Maps a Classic API task priority to the corresponding POSIX thread priority.

CALLING SEQUENCE:

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

PARAMETERS:

scheduler_id

This parameter is the scheduler identifier.

priority

This parameter is the Classic API task priority to map.

posix_priority

This parameter is the pointer to an int object. When the directive call is successful, the POSIX thread priority value corresponding to the specified Classic API task priority value will be stored in this object.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ADDRESS

The posix_priority parameter was NULL.

RTEMS_INVALID_ID

There was no scheduler associated with the identifier specified by scheduler_id.

RTEMS_INVALID_PRIORITY

The Classic API task priority was invalid.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.6. rtems_scheduler_map_priority_from_posix()

Maps a POSIX thread priority to the corresponding Classic API task priority.

CALLING SEQUENCE:

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

PARAMETERS:

scheduler_id

This parameter is the scheduler identifier.

posix_priority

This parameter is the POSIX thread priority to map.

priority

This parameter is the pointer to an rtems_task_priority object. When the directive call is successful, the Classic API task priority value corresponding to the specified POSIX thread priority value will be stored in this object.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ADDRESS

The priority parameter was NULL.

RTEMS_INVALID_ID

There was no scheduler associated with the identifier specified by scheduler_id.

RTEMS_INVALID_PRIORITY

The POSIX thread priority was invalid.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.7. rtems_scheduler_get_processor()

Returns the index of the current processor.

CALLING SEQUENCE:

uint32_t rtems_scheduler_get_processor( void );

DESCRIPTION:

Where the system was built with SMP support disabled, this directive evaluates to a compile time constant of zero.

Where the system was built with SMP support enabled, this directive returns the index of the current processor. The set of processor indices is the range of integers starting with zero up to rtems_scheduler_get_processor_maximum() minus one.

RETURN VALUES:

Returns the index of the current processor.

NOTES:

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.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.8. rtems_scheduler_get_processor_maximum()

Returns the processor maximum supported by the system.

CALLING SEQUENCE:

uint32_t rtems_scheduler_get_processor_maximum( void );

DESCRIPTION:

Where the system was built with SMP support disabled, this directive evaluates to a compile time constant of one.

Where the system was built with SMP support enabled, this directive returns the minimum of the processors (physically or virtually) available at the target and the configured processor maximum (see CONFIGURE_MAXIMUM_PROCESSORS). 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).

RETURN VALUES:

Returns the processor maximum supported by the system.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.9. rtems_scheduler_get_processor_set()

Gets the set of processors owned by the scheduler.

CALLING SEQUENCE:

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

PARAMETERS:

scheduler_id

This parameter is the scheduler identifier.

cpusetsize

This parameter is the size of the processor set referenced by cpuset in bytes.

cpuset

This parameter is the pointer to a cpu_set_t object. When the directive call is successful, the processor set of the scheduler will be stored in this object. A set bit in the processor set means that the corresponding processor is owned by the scheduler, otherwise the bit is cleared.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ADDRESS

The cpuset parameter was NULL.

RTEMS_INVALID_ID

There was no scheduler associated with the identifier specified by scheduler_id.

RTEMS_INVALID_SIZE

The provided processor set was too small for the set of processors owned by the scheduler.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within any runtime context.

  • The directive will not cause the calling task to be preempted.

5.5.10. rtems_scheduler_add_processor()

Adds the processor to the set of processors owned by the scheduler.

CALLING SEQUENCE:

rtems_status_code rtems_scheduler_add_processor(
  rtems_id scheduler_id,
  uint32_t cpu_index
);

PARAMETERS:

scheduler_id

This parameter is the scheduler identifier.

cpu_index

This parameter is the index of the processor to add.

DESCRIPTION:

This directive adds the processor specified by the cpu_index to the scheduler specified by scheduler_id.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ID

There was no scheduler associated with the identifier specified by scheduler_id.

RTEMS_NOT_CONFIGURED

The processor was not configured to be used by the application.

RTEMS_INCORRECT_STATE

The processor was configured to be used by the application, however, it was not online.

RTEMS_RESOURCE_IN_USE

The processor was already assigned to a scheduler.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within device driver initialization context.

  • The directive may be called from within task context.

  • The directive may obtain and release the object allocator mutex. This may cause the calling task to be preempted.

5.5.11. rtems_scheduler_remove_processor()

Removes the processor from the set of processors owned by the scheduler.

CALLING SEQUENCE:

rtems_status_code rtems_scheduler_remove_processor(
  rtems_id scheduler_id,
  uint32_t cpu_index
);

PARAMETERS:

scheduler_id

This parameter is the scheduler identifier.

cpu_index

This parameter is the index of the processor to remove.

DESCRIPTION:

This directive removes the processor specified by the cpu_index from the scheduler specified by scheduler_id.

RETURN VALUES:

RTEMS_SUCCESSFUL

The requested operation was successful.

RTEMS_INVALID_ID

There was no scheduler associated with the identifier specified by scheduler_id.

RTEMS_INVALID_NUMBER

The processor was not owned by the scheduler.

RTEMS_RESOURCE_IN_USE

The processor was required by at least one non-idle task that used the scheduler as its home scheduler.

RTEMS_RESOURCE_IN_USE

The processor was the last processor owned by the scheduler and there was at least one task that used the scheduler as a helping scheduler.

NOTES:

Removing a processor from a scheduler is a complex operation that involves all tasks of the system.

CONSTRAINTS:

The following constraints apply to this directive:

  • The directive may be called from within device driver initialization context.

  • The directive may be called from within task context.

  • The directive may obtain and release the object allocator mutex. This may cause the calling task to be preempted.