summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/tasksetscheduler.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-30 14:08:18 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-07-01 11:51:49 +0200
commitc0bd0064ac41f0602c0abfe494dbe140d7c5282f (patch)
treeaaa200033234cf2d3833305f13565171521b0d26 /cpukit/rtems/src/tasksetscheduler.c
parentscore: Workaround for #2751 (diff)
downloadrtems-c0bd0064ac41f0602c0abfe494dbe140d7c5282f.tar.bz2
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.
Diffstat (limited to 'cpukit/rtems/src/tasksetscheduler.c')
-rw-r--r--cpukit/rtems/src/tasksetscheduler.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/cpukit/rtems/src/tasksetscheduler.c b/cpukit/rtems/src/tasksetscheduler.c
index 36fb46d629..175f235f02 100644
--- a/cpukit/rtems/src/tasksetscheduler.c
+++ b/cpukit/rtems/src/tasksetscheduler.c
@@ -16,12 +16,14 @@
#include "config.h"
#endif
-#include <rtems/rtems/tasks.h>
+#include <rtems/rtems/tasksimpl.h>
+#include <rtems/rtems/statusimpl.h>
#include <rtems/score/schedulerimpl.h>
rtems_status_code rtems_task_set_scheduler(
- rtems_id task_id,
- rtems_id scheduler_id
+ rtems_id task_id,
+ rtems_id scheduler_id,
+ rtems_task_priority priority
)
{
const Scheduler_Control *scheduler;
@@ -30,12 +32,19 @@ rtems_status_code rtems_task_set_scheduler(
ISR_lock_Context state_lock_context;
Per_CPU_Control *cpu_self;
void *lock;
- bool ok;
+ bool valid;
+ Priority_Control core_priority;
+ Status_Control status;
if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
return RTEMS_INVALID_ID;
}
+ core_priority = _RTEMS_Priority_To_core( scheduler, priority, &valid );
+ if ( !valid ) {
+ return RTEMS_INVALID_PRIORITY;
+ }
+
the_thread = _Thread_Get( task_id, &lock_context );
if ( the_thread == NULL ) {
@@ -54,10 +63,10 @@ rtems_status_code rtems_task_set_scheduler(
lock = _Thread_Lock_acquire( the_thread, &lock_context );
_Thread_State_acquire_critical( the_thread, &state_lock_context );
- ok = _Scheduler_Set( scheduler, the_thread );
+ status = _Scheduler_Set( scheduler, the_thread, core_priority );
_Thread_State_release_critical( the_thread, &state_lock_context );
_Thread_Lock_release( lock, &lock_context );
_Thread_Dispatch_enable( cpu_self );
- return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
+ return _Status_Get( status );
}