summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/Makefile.am2
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h35
-rw-r--r--cpukit/rtems/src/taskgetscheduler.c60
-rw-r--r--cpukit/rtems/src/tasksetscheduler.c58
4 files changed, 155 insertions, 0 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index ff3e60588f..4b84fa1343 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -94,6 +94,7 @@ librtems_a_SOURCES += src/taskcreate.c
librtems_a_SOURCES += src/taskdelete.c
librtems_a_SOURCES += src/taskgetaffinity.c
librtems_a_SOURCES += src/taskgetnote.c
+librtems_a_SOURCES += src/taskgetscheduler.c
librtems_a_SOURCES += src/taskident.c
librtems_a_SOURCES += src/taskinitusers.c
librtems_a_SOURCES += src/taskissuspended.c
@@ -104,6 +105,7 @@ librtems_a_SOURCES += src/taskself.c
librtems_a_SOURCES += src/tasksetaffinity.c
librtems_a_SOURCES += src/tasksetnote.c
librtems_a_SOURCES += src/tasksetpriority.c
+librtems_a_SOURCES += src/tasksetscheduler.c
librtems_a_SOURCES += src/taskstart.c
librtems_a_SOURCES += src/tasksuspend.c
librtems_a_SOURCES += src/taskwakeafter.c
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 21c0166981..9101d9c063 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -542,6 +542,41 @@ rtems_status_code rtems_task_set_affinity(
#endif
/**
+ * @brief Gets the scheduler of a task.
+ *
+ * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the
+ * executing task.
+ * @param[out] scheduler_id Identifier of the scheduler.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The @a scheduler_id parameter is @c NULL.
+ * @retval RTEMS_INVALID_ID Invalid task identifier.
+ */
+rtems_status_code rtems_task_get_scheduler(
+ rtems_id id,
+ rtems_id *scheduler_id
+);
+
+/**
+ * @brief Sets the scheduler of a task.
+ *
+ * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the
+ * executing task.
+ * @param[in] scheduler_id Identifier of the scheduler.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier.
+ * @retval RTEMS_INCORRECT_STATE The task is in the wrong state to perform a
+ * scheduler change.
+ *
+ * @see rtems_scheduler_ident().
+ */
+rtems_status_code rtems_task_set_scheduler(
+ rtems_id id,
+ rtems_id scheduler_id
+);
+
+/**
* @brief RTEMS Get Self Task Id
*
* This directive returns the ID of the currently executing task.
diff --git a/cpukit/rtems/src/taskgetscheduler.c b/cpukit/rtems/src/taskgetscheduler.c
new file mode 100644
index 0000000000..711109304d
--- /dev/null
+++ b/cpukit/rtems/src/taskgetscheduler.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/rtems/tasks.h>
+#include <rtems/score/schedulerimpl.h>
+
+rtems_status_code rtems_task_get_scheduler(
+ rtems_id id,
+ rtems_id *scheduler_id
+)
+{
+ rtems_status_code sc;
+
+ if ( scheduler_id != NULL ) {
+ Thread_Control *the_thread;
+ Objects_Locations location;
+ const Scheduler_Control *scheduler;
+
+ the_thread = _Thread_Get( id, &location );
+
+ switch ( location ) {
+ case OBJECTS_LOCAL:
+ scheduler = _Scheduler_Get( the_thread );
+ *scheduler_id = _Scheduler_Build_id(
+ _Scheduler_Get_index( scheduler )
+ );
+ _Objects_Put( &the_thread->Object );
+ sc = RTEMS_SUCCESSFUL;
+ break;
+#if defined(RTEMS_MULTIPROCESSING)
+ case OBJECTS_REMOTE:
+ _Thread_Dispatch();
+ sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
+ break;
+#endif
+ default:
+ sc = RTEMS_INVALID_ID;
+ break;
+ }
+ } else {
+ sc = RTEMS_INVALID_ADDRESS;
+ }
+
+ return sc;
+}
diff --git a/cpukit/rtems/src/tasksetscheduler.c b/cpukit/rtems/src/tasksetscheduler.c
new file mode 100644
index 0000000000..42c08bbb80
--- /dev/null
+++ b/cpukit/rtems/src/tasksetscheduler.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/rtems/tasks.h>
+#include <rtems/score/schedulerimpl.h>
+
+rtems_status_code rtems_task_set_scheduler(
+ rtems_id id,
+ rtems_id scheduler_id
+)
+{
+ rtems_status_code sc;
+ const Scheduler_Control *scheduler;
+
+ if ( _Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
+ Thread_Control *the_thread;
+ Objects_Locations location;
+ bool ok;
+
+ the_thread = _Thread_Get( id, &location );
+
+ switch ( location ) {
+ case OBJECTS_LOCAL:
+ ok = _Scheduler_Set( scheduler, the_thread );
+ _Objects_Put( &the_thread->Object );
+ sc = ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
+ break;
+#if defined(RTEMS_MULTIPROCESSING)
+ case OBJECTS_REMOTE:
+ _Thread_Dispatch();
+ sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
+ break;
+#endif
+ default:
+ sc = RTEMS_INVALID_ID;
+ break;
+ }
+ } else {
+ sc = RTEMS_INVALID_ID;
+ }
+
+ return sc;
+}