From 835b88b883fa7c46a6a164612468f2c81af6cd69 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 7 Jul 2014 16:41:03 +0200 Subject: score: Rename _Scheduler_SMP_Update_heir() Rename and move _Scheduler_SMP_Update_heir() to _Thread_Dispatch_update_heir() since this function is not scheduler specific. --- .../score/include/rtems/score/schedulersmpimpl.h | 32 ++------------------ cpukit/score/include/rtems/score/threadimpl.h | 34 ++++++++++++++++++++-- cpukit/score/src/schedulerpriorityaffinitysmp.c | 2 +- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h index be515635ad..3bd4795ce7 100644 --- a/cpukit/score/include/rtems/score/schedulersmpimpl.h +++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h @@ -410,34 +410,6 @@ static inline bool _Scheduler_SMP_Is_processor_owned_by_us( return cpu->scheduler_context == context; } -static inline void _Scheduler_SMP_Update_heir( - Per_CPU_Control *cpu_self, - Per_CPU_Control *cpu_for_heir, - Thread_Control *heir -) -{ - cpu_for_heir->heir = heir; - - /* - * It is critical that we first update the heir and then the dispatch - * necessary so that _Thread_Get_heir_and_make_it_executing() cannot miss an - * update. - */ - _Atomic_Fence( ATOMIC_ORDER_SEQ_CST ); - - /* - * Only update the dispatch necessary indicator if not already set to - * avoid superfluous inter-processor interrupts. - */ - if ( !cpu_for_heir->dispatch_necessary ) { - cpu_for_heir->dispatch_necessary = true; - - if ( cpu_for_heir != cpu_self ) { - _Per_CPU_Send_interrupt( cpu_for_heir ); - } - } -} - static inline void _Scheduler_SMP_Allocate_processor( Scheduler_Context *context, Scheduler_Node *scheduled, @@ -461,7 +433,7 @@ static inline void _Scheduler_SMP_Allocate_processor( if ( _Thread_Is_executing_on_a_processor( scheduled_thread ) ) { if ( _Scheduler_SMP_Is_processor_owned_by_us( context, scheduled_cpu ) ) { heir = scheduled_cpu->heir; - _Scheduler_SMP_Update_heir( + _Thread_Dispatch_update_heir( cpu_self, scheduled_cpu, scheduled_thread @@ -479,7 +451,7 @@ static inline void _Scheduler_SMP_Allocate_processor( if ( heir != victim_thread ) { _Thread_Set_CPU( heir, victim_cpu ); - _Scheduler_SMP_Update_heir( cpu_self, victim_cpu, heir ); + _Thread_Dispatch_update_heir( cpu_self, victim_cpu, heir ); } } diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index b602b342de..4971e9d274 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -635,7 +635,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Signal_notification( Thread_Control *thread ) * @return The heir thread. * * @see _Thread_Dispatch(), _Thread_Start_multitasking() and - * _Scheduler_SMP_Update_heir(). + * _Thread_Dispatch_update_heir(). */ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( Per_CPU_Control *cpu_self @@ -649,7 +649,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( /* * It is critical that we first update the dispatch necessary and then the * read the heir so that we don't miss an update by - * _Scheduler_SMP_Update_heir(). + * _Thread_Dispatch_update_heir(). */ _Atomic_Fence( ATOMIC_ORDER_SEQ_CST ); #endif @@ -660,6 +660,36 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( return heir; } +#if defined( RTEMS_SMP ) +RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir( + Per_CPU_Control *cpu_self, + Per_CPU_Control *cpu_for_heir, + Thread_Control *heir +) +{ + cpu_for_heir->heir = heir; + + /* + * It is critical that we first update the heir and then the dispatch + * necessary so that _Thread_Get_heir_and_make_it_executing() cannot miss an + * update. + */ + _Atomic_Fence( ATOMIC_ORDER_SEQ_CST ); + + /* + * Only update the dispatch necessary indicator if not already set to + * avoid superfluous inter-processor interrupts. + */ + if ( !cpu_for_heir->dispatch_necessary ) { + cpu_for_heir->dispatch_necessary = true; + + if ( cpu_for_heir != cpu_self ) { + _Per_CPU_Send_interrupt( cpu_for_heir ); + } + } +} +#endif + RTEMS_INLINE_ROUTINE void _Thread_Update_cpu_time_used( Thread_Control *executing, Timestamp_Control *time_of_last_context_switch diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c index bc240544d9..f1e2252b2e 100644 --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c @@ -127,7 +127,7 @@ static inline void _Scheduler_SMP_Allocate_processor_exact( ); _Thread_Set_CPU( scheduled_thread, victim_cpu ); - _Scheduler_SMP_Update_heir( cpu_self, victim_cpu, scheduled_thread ); + _Thread_Dispatch_update_heir( cpu_self, victim_cpu, scheduled_thread ); } /* -- cgit v1.2.3