Changeset c0bd006 in rtems for cpukit/rtems


Ignore:
Timestamp:
Jun 30, 2016, 12:08:18 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
4cb13c39
Parents:
8d5b0380
git-author:
Sebastian Huber <sebastian.huber@…> (06/30/16 12:08:18)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/01/16 09:51:49)
Message:

rtems: Fix rtems_task_set_scheduler() API

Task priorities are only valid within a scheduler instance. The
rtems_task_set_scheduler() directive moves a task from one scheduler
instance to another using the current priority of the thread. However,
the current task priority of the source scheduler instance is undefined
in the target scheduler instance. Add a third parameter to specify the
priority.

Close #2749.

Location:
cpukit/rtems
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/tasks.h

    r8d5b0380 rc0bd006  
    449449
    450450/**
    451  * @brief Sets the scheduler of a task.
    452  *
    453  * The scheduler of a task is initialized to the scheduler of the task that
    454  * created it.
     451 * @brief Sets the scheduler instance of a task.
     452 *
     453 * Initially, the scheduler instance of a task is set to the scheduler instance
     454 * of the task that created it.  This directive allows to move a task from its
     455 * current scheduler instance to another specified by the scheduler identifier.
    455456 *
    456457 * @param[in] task_id Identifier of the task.  Use @ref RTEMS_SELF to select
    457  * the executing task.
    458  * @param[in] scheduler_id Identifier of the scheduler.
     458 *   the executing task.
     459 * @param[in] scheduler_id Identifier of the scheduler instance.
     460 * @param[in] priority The task priority with respect to the new scheduler
     461 *   instance.  The real and initial priority of the task is set to this value.
     462 *   The initial priority is used by rtems_task_restart() for example.
    459463 *
    460464 * @retval RTEMS_SUCCESSFUL Successful operation.
     465 * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks.
    461466 * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier.
     467 * @retval RTEMS_INVALID_PRIORITY Invalid priority.
     468 * @retval RTEMS_RESOURCE_IN_USE The task owns resources which deny a scheduler
     469 *   change.
    462470 *
    463471 * @see rtems_scheduler_ident().
    464472 */
    465473rtems_status_code rtems_task_set_scheduler(
    466   rtems_id task_id,
    467   rtems_id scheduler_id
     474  rtems_id            task_id,
     475  rtems_id            scheduler_id,
     476  rtems_task_priority priority
    468477);
    469478
  • cpukit/rtems/src/tasksetscheduler.c

    r8d5b0380 rc0bd006  
    1717#endif
    1818
    19 #include <rtems/rtems/tasks.h>
     19#include <rtems/rtems/tasksimpl.h>
     20#include <rtems/rtems/statusimpl.h>
    2021#include <rtems/score/schedulerimpl.h>
    2122
    2223rtems_status_code rtems_task_set_scheduler(
    23   rtems_id task_id,
    24   rtems_id scheduler_id
     24  rtems_id            task_id,
     25  rtems_id            scheduler_id,
     26  rtems_task_priority priority
    2527)
    2628{
     
    3133  Per_CPU_Control         *cpu_self;
    3234  void                    *lock;
    33   bool                     ok;
     35  bool                     valid;
     36  Priority_Control         core_priority;
     37  Status_Control           status;
    3438
    3539  if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
    3640    return RTEMS_INVALID_ID;
     41  }
     42
     43  core_priority = _RTEMS_Priority_To_core( scheduler, priority, &valid );
     44  if ( !valid ) {
     45    return RTEMS_INVALID_PRIORITY;
    3746  }
    3847
     
    5564  _Thread_State_acquire_critical( the_thread, &state_lock_context );
    5665
    57   ok = _Scheduler_Set( scheduler, the_thread );
     66  status = _Scheduler_Set( scheduler, the_thread, core_priority );
    5867
    5968  _Thread_State_release_critical( the_thread, &state_lock_context );
    6069  _Thread_Lock_release( lock, &lock_context );
    6170  _Thread_Dispatch_enable( cpu_self );
    62   return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
     71  return _Status_Get( status );
    6372}
Note: See TracChangeset for help on using the changeset viewer.