diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-07-11 09:51:43 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-07-11 14:16:59 +0200 |
commit | ecabd3849625e690e3c5e218285251baf2a54645 (patch) | |
tree | ec87fd8d0ad0f0ca2d08bbbc6ca0e41216f041a6 /cpukit | |
parent | rtems: Add rtems_scheduler_ident_by_processor() (diff) | |
download | rtems-ecabd3849625e690e3c5e218285251baf2a54645.tar.bz2 |
rtems: Add rtems_scheduler_ident_by_processor_set
Update #3070.
Diffstat (limited to '')
-rw-r--r-- | cpukit/rtems/Makefile.am | 1 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/tasks.h | 25 | ||||
-rw-r--r-- | cpukit/rtems/src/scheduleridentbyprocessorset.c | 60 |
3 files changed, 86 insertions, 0 deletions
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 +); + +/** * @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 + * <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/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; +} |