diff options
author | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-03-06 08:37:21 -0600 |
---|---|---|
committer | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-04-03 10:46:24 -0500 |
commit | cfe457f9a61525b02c88503d7af76887b0976643 (patch) | |
tree | af14aada35aff9b9d49c6d323a8fd6ebba13a1e6 /cpukit/score/include/rtems | |
parent | samples/fileio: Fix configuration (diff) | |
download | rtems-cfe457f9a61525b02c88503d7af76887b0976643.tar.bz2 |
score: score: Add get/set affinity to Scheduler Framework.
Diffstat (limited to 'cpukit/score/include/rtems')
6 files changed, 111 insertions, 5 deletions
diff --git a/cpukit/score/include/rtems/score/cpusetimpl.h b/cpukit/score/include/rtems/score/cpusetimpl.h index a611354550..06fe3f5a8e 100644 --- a/cpukit/score/include/rtems/score/cpusetimpl.h +++ b/cpukit/score/include/rtems/score/cpusetimpl.h @@ -34,7 +34,7 @@ extern "C" { * the system correct size, that at least one * valid cpu is set and that no invalid cpus are set. */ -int _CPU_set_Is_valid( const cpu_set_t *cpuset, size_t setsize ); +bool _CPU_set_Is_valid( const cpu_set_t *cpuset, size_t setsize ); /** * _CPU_set_Show diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h index 01d0c3a25b..7aeb560691 100644 --- a/cpukit/score/include/rtems/score/scheduler.h +++ b/cpukit/score/include/rtems/score/scheduler.h @@ -22,6 +22,9 @@ #include <rtems/score/percpu.h> #include <rtems/score/chain.h> #include <rtems/score/priority.h> +#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP) + #include <sys/cpuset.h> +#endif #ifdef __cplusplus extern "C" { @@ -98,6 +101,27 @@ typedef struct { * @see _Scheduler_Start_idle(). */ void ( *start_idle )( Thread_Control *thread, Per_CPU_Control *processor ); + +#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP) + /** + * @brief Obtain the processor affinity for a thread. + * + * @see _Scheduler_Get_affinity(). + */ + bool ( *get_affinity )( Thread_Control *thread, size_t cpusetsize, cpu_set_t *cpuset ); + + /** + * @brief Set the processor affinity for a thread. + * + * @see _Scheduler_Set_affinity(). + */ + bool ( *set_affinity )( + Thread_Control *thread, + size_t cpusetsize, + const cpu_set_t *cpuset + ); +#endif + } Scheduler_Operations; /** @@ -190,6 +214,43 @@ void _Scheduler_default_Start_idle( */ extern const bool _Scheduler_FIXME_thread_priority_queues_are_broken; +#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP) + + /** + * @brief Get affinity for the default scheduler. + * + * @param[in] thread The associated thread. + * @param[in] cpusetsize The size of the cpuset. + * @param[out] cpuset Affinity set containing all CPUs. + * + * @retval 0 Successfully got cpuset + * @retval -1 The cpusetsize is invalid for the system + */ + bool _Scheduler_default_Get_affinity( + Thread_Control *thread, + size_t cpusetsize, + cpu_set_t *cpuset + ); + + /** + * @brief Set affinity for the default scheduler. + * + * @param[in] thread The associated thread. + * @param[in] cpusetsize The size of the cpuset. + * @param[in] cpuset Affinity new affinity set. + * + * @retval 0 Successful + * + * This method always returns successful and does not save + * the cpuset. + */ + bool _Scheduler_default_Set_affinity( + Thread_Control *thread, + size_t cpusetsize, + const cpu_set_t *cpuset + ); +#endif + /**@}*/ #ifdef __cplusplus diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h index a031715a6b..72f239fd6b 100644 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ b/cpukit/score/include/rtems/score/schedulerimpl.h @@ -240,6 +240,38 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle( ( *_Scheduler.Operations.start_idle )( thread, processor ); } +#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP) + /** + * @brief Obtain the processor affinity for a thread. + * + * @param[in,out] thread The thread. + * @parma[out] cpuset The processor affinity for this thread + */ + RTEMS_INLINE_ROUTINE int _Scheduler_Get_affinity( + Thread_Control *thread, + size_t cpusetsize, + cpu_set_t *cpuset + ) + { + return (*_Scheduler.Operations.get_affinity)( thread, cpusetsize, cpuset ); + } + + /** + * @brief Set the processor affinity for a thread. + * + * @param[in,out] thread The thread. + * @parma[in] cpuset The processor affinity for this thread + */ + RTEMS_INLINE_ROUTINE int _Scheduler_Set_affinity( + Thread_Control *thread, + size_t cpusetsize, + const cpu_set_t *cpuset + ) + { + return (*_Scheduler.Operations.set_affinity)( thread, cpusetsize, cpuset ); + } +#endif + RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir( Thread_Control *heir, bool force_dispatch diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h index 40e784badf..0bc455293c 100644 --- a/cpukit/score/include/rtems/score/schedulerpriority.h +++ b/cpukit/score/include/rtems/score/schedulerpriority.h @@ -34,6 +34,14 @@ extern "C" { */ /**@{*/ +#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP) + #define SCHEDULER_PRIORITY_ADDITIONAL_SMP_ENTRY_POINTS \ + _Scheduler_default_Get_affinity, /* get affinity entry point */ \ + _Scheduler_default_Set_affinity /* set affinity entry point */ +#else + #define SCHEDULER_PRIORITY_ADDITIONAL_SMP_ENTRY_POINTS +#endif + /** * Entry points for the Deterministic Priority Based Scheduler. */ @@ -53,7 +61,8 @@ extern "C" { _Scheduler_priority_Priority_compare, /* compares two priorities */ \ _Scheduler_default_Release_job, /* new period of task */ \ _Scheduler_default_Tick, /* tick entry point */ \ - _Scheduler_default_Start_idle /* start idle entry point */ \ + _Scheduler_default_Start_idle, /* start idle entry point */ \ + SCHEDULER_PRIORITY_ADDITIONAL_SMP_ENTRY_POINTS \ } typedef struct { diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h index f30b706ef3..409d9febfa 100644 --- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h +++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h @@ -48,7 +48,7 @@ extern "C" { */ /** - * @brief Entry points for the Simple SMP Scheduler. + * @brief Entry points for the Priority SMP Scheduler. */ #define SCHEDULER_PRIORITY_SMP_ENTRY_POINTS \ { \ @@ -66,7 +66,9 @@ extern "C" { _Scheduler_priority_Priority_compare, \ _Scheduler_default_Release_job, \ _Scheduler_default_Tick, \ - _Scheduler_priority_SMP_Start_idle \ + _Scheduler_priority_SMP_Start_idle, \ + _Scheduler_default_Get_affinity, \ + _Scheduler_default_Set_affinity \ } void _Scheduler_priority_SMP_Initialize( void ); diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h index 01ebf037a3..000a975c93 100644 --- a/cpukit/score/include/rtems/score/schedulersimplesmp.h +++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h @@ -68,7 +68,9 @@ extern "C" { _Scheduler_priority_Priority_compare, \ _Scheduler_default_Release_job, \ _Scheduler_default_Tick, \ - _Scheduler_simple_smp_Start_idle \ + _Scheduler_simple_smp_Start_idle, \ + _Scheduler_default_Get_affinity, \ + _Scheduler_default_Set_affinity \ } void _Scheduler_simple_smp_Initialize( void ); |