From 0c551f76e5432941d535bf8cf4ed5b6809e5f13e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 8 Aug 2013 08:45:33 +0200 Subject: score: Add _Scheduler_priority_Get_scheduler_info Add and use _Scheduler_priority_Get_scheduler_info(). --- .../include/rtems/score/schedulerpriorityimpl.h | 61 ++++++++++------------ cpukit/score/src/schedulerpriorityallocate.c | 14 ++--- cpukit/score/src/schedulerpriorityupdate.c | 10 ++-- cpukit/score/src/schedulerpriorityyield.c | 15 +++--- 4 files changed, 44 insertions(+), 56 deletions(-) diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h index 73c635dced..7400e58734 100644 --- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h +++ b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h @@ -57,6 +57,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(void) _Chain_Initialize_empty( &ready_queues[index] ); } +RTEMS_INLINE_ROUTINE Scheduler_priority_Per_thread * +_Scheduler_priority_Get_scheduler_info( Thread_Control *thread ) +{ + return ( Scheduler_priority_Per_thread * ) thread->scheduler_info; +} + /** * @brief Put a thread to the ready queue. * @@ -68,15 +74,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue( Thread_Control *the_thread ) { - Scheduler_priority_Per_thread *sched_info; - Chain_Control *ready; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Scheduler_priority_Get_scheduler_info( the_thread ); + Chain_Control *ready_chain = sched_info_of_thread->ready_chain; - sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info; - ready = sched_info->ready_chain; - - _Priority_bit_map_Add( &sched_info->Priority_map ); - - _Chain_Append_unprotected( ready, &the_thread->Object.Node ); + _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node ); + _Priority_bit_map_Add( &sched_info_of_thread->Priority_map ); } /** @@ -92,16 +95,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first( Thread_Control *the_thread ) { - Scheduler_priority_Per_thread *sched_info; - - sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Scheduler_priority_Get_scheduler_info( the_thread ); + Chain_Control *ready_chain = sched_info_of_thread->ready_chain; - _Priority_bit_map_Add( &sched_info->Priority_map ); - - _Chain_Prepend_unprotected( - sched_info->ready_chain, - &the_thread->Object.Node - ); + _Chain_Prepend_unprotected( ready_chain, &the_thread->Object.Node ); + _Priority_bit_map_Add( &sched_info_of_thread->Priority_map ); } /** @@ -116,15 +115,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract( Thread_Control *the_thread ) { - Scheduler_priority_Per_thread *sched_info; - Chain_Control *ready; - - sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info; - ready = sched_info->ready_chain; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Scheduler_priority_Get_scheduler_info( the_thread ); + Chain_Control *ready_chain = sched_info_of_thread->ready_chain; - if ( _Chain_Has_only_one_node( ready ) ) { - _Chain_Initialize_empty( ready ); - _Priority_bit_map_Remove( &sched_info->Priority_map ); + if ( _Chain_Has_only_one_node( ready_chain ) ) { + _Chain_Initialize_empty( ready_chain ); + _Priority_bit_map_Remove( &sched_info_of_thread->Priority_map ); } else { _Chain_Extract_unprotected( &the_thread->Object.Node ); } @@ -163,17 +160,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue( Thread_Control *the_thread ) { - Scheduler_priority_Per_thread *sched_info; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Scheduler_priority_Get_scheduler_info( the_thread ); + Chain_Control *ready_chain = sched_info_of_thread->ready_chain; - sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info; - - if ( !_Chain_Has_only_one_node( sched_info->ready_chain ) ) { + if ( !_Chain_Has_only_one_node( ready_chain ) ) { _Chain_Extract_unprotected( &the_thread->Object.Node ); - - _Chain_Append_unprotected( - sched_info->ready_chain, - &the_thread->Object.Node - ); + _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node ); } } diff --git a/cpukit/score/src/schedulerpriorityallocate.c b/cpukit/score/src/schedulerpriorityallocate.c index 8c2291fa7a..ec0f21042d 100644 --- a/cpukit/score/src/schedulerpriorityallocate.c +++ b/cpukit/score/src/schedulerpriorityallocate.c @@ -18,21 +18,17 @@ #include "config.h" #endif -#include -#include -#include #include #include -void* _Scheduler_priority_Allocate ( +void *_Scheduler_priority_Allocate ( Thread_Control *the_thread ) { - void *sched; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Workspace_Allocate( sizeof( *sched_info_of_thread ) ); - sched = _Workspace_Allocate( sizeof(Scheduler_priority_Per_thread) ); + the_thread->scheduler_info = sched_info_of_thread; - the_thread->scheduler_info = (Scheduler_priority_Per_thread*) sched; - - return sched; + return sched_info_of_thread; } diff --git a/cpukit/score/src/schedulerpriorityupdate.c b/cpukit/score/src/schedulerpriorityupdate.c index aa54d31ccd..1935e137f1 100644 --- a/cpukit/score/src/schedulerpriorityupdate.c +++ b/cpukit/score/src/schedulerpriorityupdate.c @@ -25,16 +25,16 @@ void _Scheduler_priority_Update( Thread_Control *the_thread ) { - Scheduler_priority_Per_thread *sched_info; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Scheduler_priority_Get_scheduler_info( the_thread ); Chain_Control *rq; - sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info; - rq = (Chain_Control *) _Scheduler.information; + rq = (Chain_Control *) _Scheduler.information; - sched_info->ready_chain = &rq[ the_thread->current_priority ]; + sched_info_of_thread->ready_chain = &rq[ the_thread->current_priority ]; _Priority_bit_map_Initialize_information( - &sched_info->Priority_map, + &sched_info_of_thread->Priority_map, the_thread->current_priority ); } diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c index fa9a1f1271..9fdf719878 100644 --- a/cpukit/score/src/schedulerpriorityyield.c +++ b/cpukit/score/src/schedulerpriorityyield.c @@ -24,21 +24,20 @@ void _Scheduler_priority_Yield( Thread_Control *thread ) { - Scheduler_priority_Per_thread *sched_info; - ISR_Level level; - Chain_Control *ready; + Scheduler_priority_Per_thread *sched_info_of_thread = + _Scheduler_priority_Get_scheduler_info( thread ); + Chain_Control *ready_chain = sched_info_of_thread->ready_chain; + ISR_Level level; - sched_info = (Scheduler_priority_Per_thread *) thread->scheduler_info; - ready = sched_info->ready_chain; _ISR_Disable( level ); - if ( !_Chain_Has_only_one_node( ready ) ) { + if ( !_Chain_Has_only_one_node( ready_chain ) ) { _Chain_Extract_unprotected( &thread->Object.Node ); - _Chain_Append_unprotected( ready, &thread->Object.Node ); + _Chain_Append_unprotected( ready_chain, &thread->Object.Node ); _ISR_Flash( level ); if ( _Thread_Is_heir( thread ) ) - _Thread_Heir = (Thread_Control *) _Chain_First( ready ); + _Thread_Heir = (Thread_Control *) _Chain_First( ready_chain ); _Thread_Dispatch_necessary = true; } else if ( !_Thread_Is_heir( thread ) ) -- cgit v1.2.3