On Tue, Jul 11, 2017 at 9:41 AM, Sebastian Huber <sebastian.hu...@embedded-brains.de> wrote: > Update #3070. > --- > cpukit/rtems/Makefile.am | 1 + > cpukit/rtems/include/rtems/rtems/tasks.h | 25 +++++++++++ > cpukit/rtems/src/scheduleridentbyprocessorset.c | 60 > +++++++++++++++++++++++++ > testsuites/smptests/smpscheduler02/init.c | 11 +++++ > testsuites/sptests/spscheduler01/init.c | 19 ++++++++ > 5 files changed, 116 insertions(+) > create mode 100644 cpukit/rtems/src/scheduleridentbyprocessorset.c > > diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am > index e9ad2deb5d..da6e302e2e 100644 > --- a/cpukit/rtems/Makefile.am > +++ b/cpukit/rtems/Makefile.am > @@ -109,6 +109,7 @@ librtems_a_SOURCES += src/scheduleraddprocessor.c > librtems_a_SOURCES += src/schedulergetprocessorset.c > librtems_a_SOURCES += src/schedulerident.c > librtems_a_SOURCES += src/scheduleridentbyprocessor.c > +librtems_a_SOURCES += src/scheduleridentbyprocessorset.c > librtems_a_SOURCES += src/schedulerremoveprocessor.c > > ## RATEMON_C_FILES > diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h > b/cpukit/rtems/include/rtems/rtems/tasks.h > index e68c78989d..585f4c449c 100644 > --- a/cpukit/rtems/include/rtems/rtems/tasks.h > +++ b/cpukit/rtems/include/rtems/rtems/tasks.h > @@ -577,6 +577,31 @@ rtems_status_code rtems_scheduler_ident_by_processor( > ); > > /** > + * @brief Identifies a scheduler by a processor set. > + * > + * The scheduler is selected according to the highest numbered online > processor > + * in the specified processor set. > + * > + * @param[in] cpusetsize Size of the specified processor set buffer in > + * bytes. This value must be positive. > + * @param[out] cpuset The processor set to identify the scheduler. > + * @param[out] id The scheduler identifier associated with the processor set. > + * > + * @retval RTEMS_SUCCESSFUL Successful operation. > + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. > + * @retval RTEMS_INVALID_SIZE Invalid processor set size. > + * @retval RTEMS_INVALID_NAME The processor set contains no online processor. > + * @retval RTEMS_INCORRECT_STATE The processor set is valid, however, the > + * highest numbered online processor in the specified processor set is not > + * owned by a scheduler. > + */ > +rtems_status_code rtems_scheduler_ident_by_processor_set( > + size_t cpusetsize, > + const cpu_set_t *cpuset, > + rtems_id *id > +); > + Also needs doc. I wonder if "identify" or "id" may be better. "ident" seems a bit unusual.
> +/** > * @brief Gets the set of processors owned by the specified scheduler > instance. > * > * @param[in] scheduler_id Identifier of the scheduler instance. > diff --git a/cpukit/rtems/src/scheduleridentbyprocessorset.c > b/cpukit/rtems/src/scheduleridentbyprocessorset.c > new file mode 100644 > index 0000000000..4988ed0fb8 > --- /dev/null > +++ b/cpukit/rtems/src/scheduleridentbyprocessorset.c > @@ -0,0 +1,60 @@ > +/* > + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * <rt...@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/assert.h> > +#include <rtems/score/schedulerimpl.h> > + > +rtems_status_code rtems_scheduler_ident_by_processor_set( > + size_t cpusetsize, > + const cpu_set_t *cpuset, > + rtems_id *id > +) > +{ > + Processor_mask set; > + Processor_mask_Copy_status status; > + uint32_t cpu_index; > + const Scheduler_Control *scheduler; > + > + if ( id == NULL ) { > + return RTEMS_INVALID_ADDRESS; > + } > + > + status = _Processor_mask_From_cpu_set_t( &set, cpusetsize, cpuset ); > + if ( status == PROCESSOR_MASK_COPY_INVALID_SIZE ) { > + return RTEMS_INVALID_SIZE; > + } > + > + _Processor_mask_And( &set, &set, _SMP_Get_online_processors() ); > + cpu_index = _Processor_mask_Find_last_set( &set ); > + if ( cpu_index == 0 ) { > + return RTEMS_INVALID_NAME; > + } > + > + scheduler = _Scheduler_Get_by_CPU( _Per_CPU_Get_by_index( cpu_index - 1) ); > +#if defined(RTEMS_SMP) > + if ( scheduler == NULL ) { > + return RTEMS_INCORRECT_STATE; > + } > +#else > + _Assert( scheduler != NULL ); > +#endif > + > + *id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) ); > + return RTEMS_SUCCESSFUL; > +} > diff --git a/testsuites/smptests/smpscheduler02/init.c > b/testsuites/smptests/smpscheduler02/init.c > index 7dd60ec4c5..3975802d4a 100644 > --- a/testsuites/smptests/smpscheduler02/init.c > +++ b/testsuites/smptests/smpscheduler02/init.c > @@ -134,8 +134,10 @@ static void test_scheduler_add_remove_processors(void) > rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE); > > if (rtems_get_processor_count() > 1) { > + rtems_id scheduler_id; > rtems_id scheduler_b_id; > rtems_id task_id; > + cpu_set_t first_cpu; > > sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id); > rtems_test_assert(sc == RTEMS_SUCCESSFUL); > @@ -153,6 +155,15 @@ static void test_scheduler_add_remove_processors(void) > > rtems_test_assert(rtems_get_current_processor() == 1); > > + CPU_ZERO(&first_cpu); > + CPU_SET(0, &first_cpu); > + sc = rtems_scheduler_ident_by_processor_set( > + sizeof(first_cpu), > + &first_cpu, > + &scheduler_id > + ); > + rtems_test_assert(sc == RTEMS_INCORRECT_STATE); > + > sc = rtems_scheduler_add_processor(scheduler_a_id, 0); > rtems_test_assert(sc == RTEMS_SUCCESSFUL); > > diff --git a/testsuites/sptests/spscheduler01/init.c > b/testsuites/sptests/spscheduler01/init.c > index 2415ace803..9840a3ebc4 100644 > --- a/testsuites/sptests/spscheduler01/init.c > +++ b/testsuites/sptests/spscheduler01/init.c > @@ -343,6 +343,7 @@ static void test_scheduler_ident(void) > rtems_id scheduler_id; > rtems_name name = BLUE; > rtems_name invalid_name = RED; > + cpu_set_t s; > > sc = rtems_scheduler_ident(name, NULL); > rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); > @@ -367,6 +368,24 @@ static void test_scheduler_ident(void) > rtems_test_assert(sc == RTEMS_SUCCESSFUL); > > rtems_test_assert(scheduler_id == expected_id); > + > + CPU_ZERO(&s); > + CPU_SET(1, &s); > + sc = rtems_scheduler_ident_by_processor_set(sizeof(s), &s, NULL); > + rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); > + > + sc = rtems_scheduler_ident_by_processor_set(1, &s, &scheduler_id); > + rtems_test_assert(sc == RTEMS_INVALID_SIZE); > + > + sc = rtems_scheduler_ident_by_processor_set(sizeof(s), &s, &scheduler_id); > + rtems_test_assert(sc == RTEMS_INVALID_NAME); > + > + CPU_SET(0, &s); > + scheduler_id = 0; > + sc = rtems_scheduler_ident_by_processor_set(sizeof(s), &s, &scheduler_id); > + rtems_test_assert(sc == RTEMS_SUCCESSFUL); > + > + rtems_test_assert(scheduler_id == expected_id); > } > > static void test_scheduler_get_processors(void) > -- > 2.12.3 > > _______________________________________________ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel