From 2612a0bf5b9f0105315d62cbacfa9d29a5caa4b5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 2 Nov 2016 06:36:13 +0100 Subject: score: Simplify _Scheduler_Get_by_id() Avoid dead code in non-SMP configurations. Return scheduler identifier independent of the current processor count of the scheduler via rtems_scheduler_ident(), since this value may change during run-time. Check the processor count in _Scheduler_Set() under scheduler lock protection. Update #2797. --- cpukit/rtems/include/rtems/rtems/tasks.h | 2 -- cpukit/rtems/src/schedulergetprocessorset.c | 3 ++- cpukit/rtems/src/schedulerident.c | 8 ++------ cpukit/rtems/src/semsetpriority.c | 3 ++- cpukit/rtems/src/taskgetpriority.c | 3 ++- cpukit/rtems/src/tasksetscheduler.c | 3 ++- 6 files changed, 10 insertions(+), 12 deletions(-) (limited to 'cpukit/rtems') diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h index 180e50eed7..3a94e348ed 100644 --- a/cpukit/rtems/include/rtems/rtems/tasks.h +++ b/cpukit/rtems/include/rtems/rtems/tasks.h @@ -555,8 +555,6 @@ void rtems_task_iterate( * @retval RTEMS_SUCCESSFUL Successful operation. * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. * @retval RTEMS_INVALID_NAME Invalid scheduler name. - * @retval RTEMS_UNSATISFIED A scheduler with this name exists, but the - * processor set of this scheduler is empty. */ rtems_status_code rtems_scheduler_ident( rtems_name name, diff --git a/cpukit/rtems/src/schedulergetprocessorset.c b/cpukit/rtems/src/schedulergetprocessorset.c index 016c3681cf..275c563090 100644 --- a/cpukit/rtems/src/schedulergetprocessorset.c +++ b/cpukit/rtems/src/schedulergetprocessorset.c @@ -34,7 +34,8 @@ rtems_status_code rtems_scheduler_get_processor_set( return RTEMS_INVALID_ADDRESS; } - if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) { + scheduler = _Scheduler_Get_by_id( scheduler_id ); + if ( scheduler == NULL ) { return RTEMS_INVALID_ID; } diff --git a/cpukit/rtems/src/schedulerident.c b/cpukit/rtems/src/schedulerident.c index ee18af009e..5bde8de8bc 100644 --- a/cpukit/rtems/src/schedulerident.c +++ b/cpukit/rtems/src/schedulerident.c @@ -36,12 +36,8 @@ rtems_status_code rtems_scheduler_ident( const Scheduler_Control *scheduler = &_Scheduler_Table[ i ]; if ( scheduler->name == name ) { - if ( _Scheduler_Get_processor_count( scheduler ) > 0 ) { - *id = _Scheduler_Build_id( i ); - sc = RTEMS_SUCCESSFUL; - } else { - sc = RTEMS_UNSATISFIED; - } + *id = _Scheduler_Build_id( i ); + sc = RTEMS_SUCCESSFUL; } } } else { diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c index 37dea5da80..123f6277af 100644 --- a/cpukit/rtems/src/semsetpriority.c +++ b/cpukit/rtems/src/semsetpriority.c @@ -138,7 +138,8 @@ rtems_status_code rtems_semaphore_set_priority( return RTEMS_INVALID_ADDRESS; } - if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) { + scheduler = _Scheduler_Get_by_id( scheduler_id ); + if ( scheduler == NULL ) { return RTEMS_INVALID_ID; } diff --git a/cpukit/rtems/src/taskgetpriority.c b/cpukit/rtems/src/taskgetpriority.c index b6800e2133..8fb8ad3b4f 100644 --- a/cpukit/rtems/src/taskgetpriority.c +++ b/cpukit/rtems/src/taskgetpriority.c @@ -36,7 +36,8 @@ rtems_status_code rtems_task_get_priority( return RTEMS_INVALID_ADDRESS; } - if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) { + scheduler = _Scheduler_Get_by_id( scheduler_id ); + if ( scheduler == NULL ) { return RTEMS_INVALID_ID; } diff --git a/cpukit/rtems/src/tasksetscheduler.c b/cpukit/rtems/src/tasksetscheduler.c index 3a860a197b..f3b7143d7b 100644 --- a/cpukit/rtems/src/tasksetscheduler.c +++ b/cpukit/rtems/src/tasksetscheduler.c @@ -35,7 +35,8 @@ rtems_status_code rtems_task_set_scheduler( Priority_Control core_priority; Status_Control status; - if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) { + scheduler = _Scheduler_Get_by_id( scheduler_id ); + if ( scheduler == NULL ) { return RTEMS_INVALID_ID; } -- cgit v1.2.3