<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style></head>
<body>
<body><p dir="ltr">I do not like the name of this method. It should be something like get default cpuset. This name is misleading and too close to something that would return a simple number of cores.</p><div class="quote">On Apr 9, 2014 6:27 AM, Sebastian Huber <sebastian.huber@embedded-brains.de> wrote:<br type="attribution"></div></body>
<font size="2"><div class="PlainText">---<br>
cpukit/rtems/Makefile.am | 1 +<br>
cpukit/rtems/include/rtems/rtems/tasks.h | 24 +++++++++<br>
cpukit/rtems/src/schedulergetprocessors.c | 59 ++++++++++++++++++++++<br>
cpukit/score/include/rtems/score/schedulerimpl.h | 13 +++++<br>
testsuites/sptests/spscheduler01/init.c | 52 +++++++++++++++++++<br>
5 files changed, 149 insertions(+), 0 deletions(-)<br>
create mode 100644 cpukit/rtems/src/schedulergetprocessors.c<br>
<br>
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am<br>
index 3962fa9..c840f24 100644<br>
--- a/cpukit/rtems/Makefile.am<br>
+++ b/cpukit/rtems/Makefile.am<br>
@@ -116,6 +116,7 @@ librtems_a_SOURCES += src/taskvariableget.c<br>
librtems_a_SOURCES += src/taskvariable_invoke_dtor.c<br>
endif<br>
librtems_a_SOURCES += src/taskdata.c<br>
+librtems_a_SOURCES += src/schedulergetprocessors.c<br>
librtems_a_SOURCES += src/schedulerident.c<br>
librtems_a_SOURCES += src/scheduleridentbyindex.c<br>
<br>
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h<br>
index fb0869e..59c5c83 100644<br>
--- a/cpukit/rtems/include/rtems/rtems/tasks.h<br>
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h<br>
@@ -584,6 +584,30 @@ rtems_status_code rtems_scheduler_ident_by_index(<br>
rtems_id *id<br>
);<br>
<br>
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)<br>
+/**<br>
+ * @brief Gets the set of processors owned by the scheduler.<br>
+ *<br>
+ * @param[in] scheduler_id Identifier of the scheduler.<br>
+ * @param[in] cpusetsize Size of the specified processor set buffer in<br>
+ * bytes. This value must be positive.<br>
+ * @param[out] cpuset The processor set owned by the scheduler. A set bit in<br>
+ * the processor set means that this processor is owned by the scheduler and a<br>
+ * cleared bit means the opposite.<br>
+ *<br>
+ * @retval RTEMS_SUCCESSFUL Successful operation.<br>
+ * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL.<br>
+ * @retval RTEMS_INVALID_ID Invalid scheduler identifier.<br>
+ * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the<br>
+ * set of processors owned by the scheduler.<br>
+ */<br>
+rtems_status_code rtems_scheduler_get_processors(<br>
+ rtems_id scheduler_id,<br>
+ size_t cpusetsize,<br>
+ cpu_set_t *cpuset<br>
+);<br>
+#endif<br>
+<br>
/**@}*/<br>
<br>
/**<br>
diff --git a/cpukit/rtems/src/schedulergetprocessors.c b/cpukit/rtems/src/schedulergetprocessors.c<br>
new file mode 100644<br>
index 0000000..42c7ae2<br>
--- /dev/null<br>
+++ b/cpukit/rtems/src/schedulergetprocessors.c<br>
@@ -0,0 +1,59 @@<br>
+/*<br>
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.<br>
+ *<br>
+ * embedded brains GmbH<br>
+ * Dornierstr. 4<br>
+ * 82178 Puchheim<br>
+ * Germany<br>
+ * <rtems@embedded-brains.de><br>
+ *<br>
+ * The license and distribution terms for this file may be<br>
+ * found in the file LICENSE in this distribution or at<br>
+ * <a href="http://www.rtems.org/license/LICENSE">http://www.rtems.org/license/LICENSE</a>.<br>
+ */<br>
+<br>
+#if HAVE_CONFIG_H<br>
+ #include "config.h"<br>
+#endif<br>
+<br>
+#include <rtems/rtems/tasks.h><br>
+#include <rtems/score/cpusetimpl.h><br>
+#include <rtems/score/schedulerimpl.h><br>
+<br>
+rtems_status_code rtems_scheduler_get_processors(<br>
+ rtems_id scheduler_id,<br>
+ size_t cpusetsize,<br>
+ cpu_set_t *cpuset<br>
+)<br>
+{<br>
+ rtems_status_code sc;<br>
+<br>
+ if ( cpuset != NULL ) {<br>
+ const Scheduler_Control *scheduler;<br>
+<br>
+ if ( _Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {<br>
+ if ( _CPU_set_Is_large_enough( cpusetsize ) ) {<br>
+ uint32_t cpu_count = _SMP_Get_processor_count();<br>
+ uint32_t cpu_index;<br>
+<br>
+ (void) scheduler;<br>
+<br>
+ CPU_ZERO_S( cpusetsize, cpuset );<br>
+<br>
+ for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {<br>
+ CPU_SET_S( (int) cpu_index, cpusetsize, cpuset );<br>
+ }<br>
+<br>
+ sc = RTEMS_SUCCESSFUL;<br>
+ } else {<br>
+ sc = RTEMS_INVALID_NUMBER;<br>
+ }<br>
+ } else {<br>
+ sc = RTEMS_INVALID_ID;<br>
+ }<br>
+ } else {<br>
+ sc = RTEMS_INVALID_ADDRESS;<br>
+ }<br>
+<br>
+ return sc;<br>
+}<br>
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h<br>
index e94c048..8a8e779 100644<br>
--- a/cpukit/score/include/rtems/score/schedulerimpl.h<br>
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h<br>
@@ -451,6 +451,19 @@ RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index )<br>
);<br>
}<br>
<br>
+RTEMS_INLINE_ROUTINE bool _Scheduler_Get_by_id(<br>
+ Objects_Id id,<br>
+ const Scheduler_Control **scheduler<br>
+)<br>
+{<br>
+ uint32_t minimum_id = _Scheduler_Build_id( 0 );<br>
+ uint32_t index = id - minimum_id;<br>
+<br>
+ *scheduler = &_Scheduler_Table[ index ];<br>
+<br>
+ return index < _Scheduler_Count;<br>
+}<br>
+<br>
/** @} */<br>
<br>
#ifdef __cplusplus<br>
diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c<br>
index 4452f60..ea50574 100644<br>
--- a/testsuites/sptests/spscheduler01/init.c<br>
+++ b/testsuites/sptests/spscheduler01/init.c<br>
@@ -131,6 +131,57 @@ static void test_scheduler_ident(void)<br>
rtems_test_assert(scheduler_id == expected_id);<br>
}<br>
<br>
+static void test_scheduler_get_processors(void)<br>
+{<br>
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)<br>
+ rtems_status_code sc;<br>
+ rtems_id scheduler_id;<br>
+ cpu_set_t cpusetone;<br>
+ cpu_set_t cpuset;<br>
+ size_t big = 2 * CHAR_BIT * sizeof(cpu_set_t);<br>
+ size_t cpusetbigsize = CPU_ALLOC_SIZE(big);<br>
+ cpu_set_t *cpusetbigone;<br>
+ cpu_set_t *cpusetbig;<br>
+<br>
+ CPU_ZERO(&cpusetone);<br>
+ CPU_SET(0, &cpusetone);<br>
+<br>
+ sc = rtems_scheduler_ident_by_index(0, &scheduler_id);<br>
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
+<br>
+ sc = rtems_scheduler_get_processors(scheduler_id, sizeof(cpuset), NULL);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);<br>
+<br>
+ sc = rtems_scheduler_get_processors(invalid_id, sizeof(cpuset), &cpuset);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_ID);<br>
+<br>
+ sc = rtems_scheduler_get_processors(scheduler_id, 0, &cpuset);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_NUMBER);<br>
+<br>
+ sc = rtems_scheduler_get_processors(scheduler_id, sizeof(cpuset), &cpuset);<br>
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
+<br>
+ rtems_test_assert(CPU_EQUAL(&cpuset, &cpusetone));<br>
+<br>
+ cpusetbigone = CPU_ALLOC(big);<br>
+ rtems_test_assert(cpusetbigone != NULL);<br>
+<br>
+ cpusetbig = CPU_ALLOC(big);<br>
+ rtems_test_assert(cpusetbig != NULL);<br>
+<br>
+ CPU_ZERO_S(cpusetbigsize, cpusetbigone);<br>
+ CPU_SET_S(0, cpusetbigsize, cpusetbigone);<br>
+<br>
+ sc = rtems_scheduler_get_processors(scheduler_id, cpusetbigsize, cpusetbig);<br>
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
+<br>
+ rtems_test_assert(CPU_EQUAL_S(cpusetbigsize, cpusetbig, cpusetbigone));<br>
+<br>
+ CPU_FREE(cpusetbig);<br>
+ CPU_FREE(cpusetbigone);<br>
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */<br>
+}<br>
+<br>
static void Init(rtems_task_argument arg)<br>
{<br>
rtems_resource_snapshot snapshot;<br>
@@ -141,6 +192,7 @@ static void Init(rtems_task_argument arg)<br>
<br>
test_task_get_set_affinity();<br>
test_scheduler_ident();<br>
+ test_scheduler_get_processors();<br>
<br>
rtems_test_assert(rtems_resource_snapshot_check(&snapshot));<br>
<br>
-- <br>
1.7.7<br>
<br>
_______________________________________________<br>
rtems-devel mailing list<br>
rtems-devel@rtems.org<br>
<a href="http://www.rtems.org/mailman/listinfo/rtems-devel">http://www.rtems.org/mailman/listinfo/rtems-devel</a><br>
</div></font>
</body>
</html>