<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 have a number of concerns about this. </p><p dir="ltr">The gap in the object type in the enum is very inconsistent with the other ids. Does it negatively impact the object class tables?</p><p dir="ltr">Does it negatively impact the RTEMS object services at the API level? Remember there are rtems_object services which work universally on any id. I think you are breaking the orthogonality of them.</p><p dir="ltr">What is the intended use case? </p><p dir="ltr">Where is documentation?</p><p dir="ltr">I assume this is part of having multiple schedulers but you are basically tossing unjustified code over the wall without giving us a plan. I have no idea why the code is desirable based on what you have said. And it breaks the uniform use of IDs.</p><p dir="ltr">--joel</p><div class="quote">On Apr 9, 2014 6:30 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 | 2 +<br>
cpukit/rtems/include/rtems/rtems/tasks.h | 36 +++++++++++++++++<br>
cpukit/rtems/src/schedulerident.c | 46 ++++++++++++++++++++++<br>
cpukit/rtems/src/scheduleridentbyindex.c | 41 +++++++++++++++++++<br>
cpukit/score/include/rtems/score/objectimpl.h | 5 ++-<br>
cpukit/score/include/rtems/score/schedulerimpl.h | 10 +++++<br>
testsuites/sptests/spscheduler01/init.c | 36 +++++++++++++++++<br>
7 files changed, 175 insertions(+), 1 deletions(-)<br>
create mode 100644 cpukit/rtems/src/schedulerident.c<br>
create mode 100644 cpukit/rtems/src/scheduleridentbyindex.c<br>
<br>
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am<br>
index 70a8855..3962fa9 100644<br>
--- a/cpukit/rtems/Makefile.am<br>
+++ b/cpukit/rtems/Makefile.am<br>
@@ -116,6 +116,8 @@ 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/schedulerident.c<br>
+librtems_a_SOURCES += src/scheduleridentbyindex.c<br>
<br>
## RATEMON_C_FILES<br>
librtems_a_SOURCES += src/ratemon.c<br>
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h<br>
index 4da32c4..fb0869e 100644<br>
--- a/cpukit/rtems/include/rtems/rtems/tasks.h<br>
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h<br>
@@ -548,6 +548,42 @@ rtems_status_code rtems_task_set_affinity(<br>
*/<br>
rtems_id rtems_task_self(void);<br>
<br>
+/**<br>
+ * @brief Identifies a scheduler by its name.<br>
+ *<br>
+ * The scheduler name is determined by the scheduler configuration.<br>
+ *<br>
+ * @param[in] name The scheduler name.<br>
+ * @param[out] id The scheduler identifier associated with the name.<br>
+ *<br>
+ * @retval RTEMS_SUCCESSFUL Successful operation.<br>
+ * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL.<br>
+ * @retval RTEMS_INVALID_NAME Invalid scheduler name.<br>
+ */<br>
+rtems_status_code rtems_scheduler_ident(<br>
+ rtems_name name,<br>
+ rtems_id *id<br>
+);<br>
+<br>
+/**<br>
+ * @brief Identifies a scheduler by its index.<br>
+ *<br>
+ * The scheduler index is determined by the scheduler configuration.<br>
+ *<br>
+ * @param[in] scheduler_index The scheduler index. The scheduler index ranges<br>
+ * from zero to the scheduler count minus one. This is in contrast to object<br>
+ * indices, which start with one.<br>
+ * @param[out] id The scheduler identifier associated with the scheduler index.<br>
+ *<br>
+ * @retval RTEMS_SUCCESSFUL Successful operation.<br>
+ * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL.<br>
+ * @retval RTEMS_INVALID_NAME Invalid scheduler index.<br>
+ */<br>
+rtems_status_code rtems_scheduler_ident_by_index(<br>
+ uint32_t scheduler_index,<br>
+ rtems_id *id<br>
+);<br>
+<br>
/**@}*/<br>
<br>
/**<br>
diff --git a/cpukit/rtems/src/schedulerident.c b/cpukit/rtems/src/schedulerident.c<br>
new file mode 100644<br>
index 0000000..d9e913c<br>
--- /dev/null<br>
+++ b/cpukit/rtems/src/schedulerident.c<br>
@@ -0,0 +1,46 @@<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/schedulerimpl.h><br>
+<br>
+rtems_status_code rtems_scheduler_ident(<br>
+ rtems_name name,<br>
+ rtems_id *id<br>
+)<br>
+{<br>
+ rtems_status_code sc;<br>
+<br>
+ if ( id != NULL ) {<br>
+ size_t n = _Scheduler_Count;<br>
+ size_t i;<br>
+<br>
+ sc = RTEMS_INVALID_NAME;<br>
+<br>
+ for ( i = 0 ; i < n && sc == RTEMS_INVALID_NAME ; ++i ) {<br>
+ if ( _Scheduler_Table[ i ].name == name ) {<br>
+ *id = _Scheduler_Build_id( i );<br>
+ sc = RTEMS_SUCCESSFUL;<br>
+ }<br>
+ }<br>
+ } else {<br>
+ sc = RTEMS_INVALID_ADDRESS;<br>
+ }<br>
+<br>
+ return sc;<br>
+}<br>
diff --git a/cpukit/rtems/src/scheduleridentbyindex.c b/cpukit/rtems/src/scheduleridentbyindex.c<br>
new file mode 100644<br>
index 0000000..66cd222<br>
--- /dev/null<br>
+++ b/cpukit/rtems/src/scheduleridentbyindex.c<br>
@@ -0,0 +1,41 @@<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/schedulerimpl.h><br>
+<br>
+rtems_status_code rtems_scheduler_ident_by_index(<br>
+ uint32_t scheduler_index,<br>
+ rtems_id *id<br>
+)<br>
+{<br>
+ rtems_status_code sc;<br>
+<br>
+ if ( id != NULL ) {<br>
+ if ( scheduler_index < _Scheduler_Count ) {<br>
+ *id = _Scheduler_Build_id( scheduler_index );<br>
+ sc = RTEMS_SUCCESSFUL;<br>
+ } else {<br>
+ sc = RTEMS_INVALID_NAME;<br>
+ }<br>
+ } else {<br>
+ sc = RTEMS_INVALID_ADDRESS;<br>
+ }<br>
+<br>
+ return sc;<br>
+}<br>
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h<br>
index 383f0a7..e47c6a8 100644<br>
--- a/cpukit/score/include/rtems/score/objectimpl.h<br>
+++ b/cpukit/score/include/rtems/score/objectimpl.h<br>
@@ -71,7 +71,10 @@ typedef enum {<br>
OBJECTS_RTEMS_PORTS = 7,<br>
OBJECTS_RTEMS_PERIODS = 8,<br>
OBJECTS_RTEMS_EXTENSIONS = 9,<br>
- OBJECTS_RTEMS_BARRIERS = 10<br>
+ OBJECTS_RTEMS_BARRIERS = 10,<br>
+<br>
+ /* The schedulers are no real objects, but they have an object identifier */<br>
+ OBJECTS_RTEMS_SCHEDULERS = 31<br>
} Objects_Classic_API;<br>
<br>
/** This macro is used to generically specify the last API index. */<br>
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h<br>
index abad068..e94c048 100644<br>
--- a/cpukit/score/include/rtems/score/schedulerimpl.h<br>
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h<br>
@@ -441,6 +441,16 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get(<br>
return &_Scheduler_Table[ 0 ];<br>
}<br>
<br>
+RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index )<br>
+{<br>
+ return _Objects_Build_id(<br>
+ OBJECTS_CLASSIC_API,<br>
+ OBJECTS_RTEMS_SCHEDULERS,<br>
+ _Objects_Local_node,<br>
+ scheduler_index + 1<br>
+ );<br>
+}<br>
+<br>
/** @} */<br>
<br>
#ifdef __cplusplus<br>
diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c<br>
index f8c4bb2..4452f60 100644<br>
--- a/testsuites/sptests/spscheduler01/init.c<br>
+++ b/testsuites/sptests/spscheduler01/init.c<br>
@@ -98,6 +98,39 @@ static void test_task_get_set_affinity(void)<br>
#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */<br>
}<br>
<br>
+static void test_scheduler_ident(void)<br>
+{<br>
+ rtems_status_code sc;<br>
+ rtems_id expected_id = rtems_build_id(2, 31, 1, 1);<br>
+ rtems_id scheduler_id;<br>
+ rtems_name name = rtems_build_name('b', 'l', 'u', 'e');<br>
+ rtems_name invalid_name = rtems_build_name(' ', 'r', 'e', 'd');<br>
+<br>
+ sc = rtems_scheduler_ident(name, NULL);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);<br>
+<br>
+ sc = rtems_scheduler_ident_by_index(0, NULL);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);<br>
+<br>
+ sc = rtems_scheduler_ident(invalid_name, &scheduler_id);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_NAME);<br>
+<br>
+ sc = rtems_scheduler_ident_by_index(1, &scheduler_id);<br>
+ rtems_test_assert(sc == RTEMS_INVALID_NAME);<br>
+<br>
+ scheduler_id = 0;<br>
+ sc = rtems_scheduler_ident(name, &scheduler_id);<br>
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
+<br>
+ rtems_test_assert(scheduler_id == expected_id);<br>
+<br>
+ scheduler_id = 0;<br>
+ sc = rtems_scheduler_ident_by_index(0, &scheduler_id);<br>
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
+<br>
+ rtems_test_assert(scheduler_id == expected_id);<br>
+}<br>
+<br>
static void Init(rtems_task_argument arg)<br>
{<br>
rtems_resource_snapshot snapshot;<br>
@@ -107,6 +140,7 @@ static void Init(rtems_task_argument arg)<br>
rtems_resource_snapshot_take(&snapshot);<br>
<br>
test_task_get_set_affinity();<br>
+ test_scheduler_ident();<br>
<br>
rtems_test_assert(rtems_resource_snapshot_check(&snapshot));<br>
<br>
@@ -125,6 +159,8 @@ static void Init(rtems_task_argument arg)<br>
<br>
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE<br>
<br>
+#define CONFIGURE_SCHEDULER_NAME rtems_build_name('b', 'l', 'u', 'e')<br>
+<br>
#define CONFIGURE_INIT<br>
<br>
#include <rtems/confdefs.h><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>