summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-09 10:09:57 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-15 09:29:35 +0200
commit1b67535d86c6a92cda1b08759293c20b7fab6978 (patch)
treec89b843dce778cdbfd1559285d690af859c36675 /cpukit
parentrtems: Add scheduler identification (diff)
downloadrtems-1b67535d86c6a92cda1b08759293c20b7fab6978.tar.bz2
rtems: Add scheduler get processors
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/rtems/Makefile.am1
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h24
-rw-r--r--cpukit/rtems/src/schedulergetprocessorset.c54
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h13
4 files changed, 92 insertions, 0 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 57b15ca097..ff3e60588f 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -116,6 +116,7 @@ librtems_a_SOURCES += src/taskvariableget.c
librtems_a_SOURCES += src/taskvariable_invoke_dtor.c
endif
librtems_a_SOURCES += src/taskdata.c
+librtems_a_SOURCES += src/schedulergetprocessorset.c
librtems_a_SOURCES += src/schedulerident.c
## RATEMON_C_FILES
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 5816e7d884..21c0166981 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -565,6 +565,30 @@ rtems_status_code rtems_scheduler_ident(
rtems_id *id
);
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+/**
+ * @brief Gets the set of processors owned by the scheduler.
+ *
+ * @param[in] scheduler_id Identifier of the scheduler.
+ * @param[in] cpusetsize Size of the specified processor set buffer in
+ * bytes. This value must be positive.
+ * @param[out] cpuset The processor set owned by the scheduler. A set bit in
+ * the processor set means that this processor is owned by the scheduler and a
+ * cleared bit means the opposite.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL.
+ * @retval RTEMS_INVALID_ID Invalid scheduler identifier.
+ * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the
+ * set of processors owned by the scheduler.
+ */
+rtems_status_code rtems_scheduler_get_processor_set(
+ rtems_id scheduler_id,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
+);
+#endif
+
/**@}*/
/**
diff --git a/cpukit/rtems/src/schedulergetprocessorset.c b/cpukit/rtems/src/schedulergetprocessorset.c
new file mode 100644
index 0000000000..e459b178cc
--- /dev/null
+++ b/cpukit/rtems/src/schedulergetprocessorset.c
@@ -0,0 +1,54 @@
+/*
+ * 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
+
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+
+#include <rtems/rtems/tasks.h>
+#include <rtems/score/cpusetimpl.h>
+#include <rtems/score/schedulerimpl.h>
+
+rtems_status_code rtems_scheduler_get_processor_set(
+ rtems_id scheduler_id,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
+)
+{
+ rtems_status_code sc;
+
+ if ( cpuset != NULL ) {
+ const Scheduler_Control *scheduler;
+
+ if ( _Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
+ if ( _CPU_set_Is_large_enough( cpusetsize ) ) {
+ _Scheduler_Get_processor_set( scheduler, cpusetsize, cpuset );
+
+ sc = RTEMS_SUCCESSFUL;
+ } else {
+ sc = RTEMS_INVALID_NUMBER;
+ }
+ } else {
+ sc = RTEMS_INVALID_ID;
+ }
+ } else {
+ sc = RTEMS_INVALID_ADDRESS;
+ }
+
+ return sc;
+}
+
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 01be51518e..2b8782fe7d 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -461,6 +461,19 @@ RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index )
);
}
+RTEMS_INLINE_ROUTINE bool _Scheduler_Get_by_id(
+ Objects_Id id,
+ const Scheduler_Control **scheduler
+)
+{
+ uint32_t minimum_id = _Scheduler_Build_id( 0 );
+ uint32_t index = id - minimum_id;
+
+ *scheduler = &_Scheduler_Table[ index ];
+
+ return index < _Scheduler_Count;
+}
+
/** @} */
#ifdef __cplusplus