From e3be6915989d79a8797b775974f501a359226319 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 27 May 2013 17:31:46 +0200 Subject: score: Remove idle field of Per_CPU_Control This field is unused except for special case simulator clock drivers. In these places use an alternative. Add and use _Thread_Set_global_exit_status() and _Thread_Get_global_exit_status(). --- c/src/lib/libbsp/shared/clockdrv_shell.h | 7 +++++-- c/src/lib/libcpu/bfin/clock/clock.c | 7 +++++-- c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c | 7 +++++-- cpukit/sapi/src/exinit.c | 4 ++-- cpukit/sapi/src/exshutdown.c | 3 +-- cpukit/score/include/rtems/score/percpu.h | 5 ----- cpukit/score/inline/rtems/score/thread.inl | 18 ++++++++++++++++++ cpukit/score/src/threadcreateidle.c | 11 ++++++----- testsuites/sptests/spsimplesched02/init.c | 13 +++++++++++-- 9 files changed, 53 insertions(+), 22 deletions(-) diff --git a/c/src/lib/libbsp/shared/clockdrv_shell.h b/c/src/lib/libbsp/shared/clockdrv_shell.h index 3e8d08c131..79192610de 100644 --- a/c/src/lib/libbsp/shared/clockdrv_shell.h +++ b/c/src/lib/libbsp/shared/clockdrv_shell.h @@ -73,8 +73,11 @@ rtems_isr Clock_isr( #ifdef CLOCK_DRIVER_USE_FAST_IDLE do { rtems_clock_tick(); - } while ( _Thread_Executing == _Thread_Idle && - _Thread_Heir == _Thread_Executing); + } while ( + _Thread_Heir == _Thread_Executing + && _Thread_Executing->Start.entry_point + == rtems_configuration_get_idle_task() + ); Clock_driver_support_at_tick(); return; diff --git a/c/src/lib/libcpu/bfin/clock/clock.c b/c/src/lib/libcpu/bfin/clock/clock.c index 530e5bad48..46525863b8 100644 --- a/c/src/lib/libcpu/bfin/clock/clock.c +++ b/c/src/lib/libcpu/bfin/clock/clock.c @@ -39,8 +39,11 @@ static rtems_isr clockISR(rtems_vector_number vector) { #ifdef CLOCK_DRIVER_USE_FAST_IDLE do { rtems_clock_tick(); - } while (_Thread_Executing == _Thread_Idle && - _Thread_Heir == _Thread_Executing); + } while ( + _Thread_Heir == _Thread_Executing + && _Thread_Executing->Start.entry_point + == rtems_configuration_get_idle_task() + ); #else rtems_clock_tick(); #endif diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c index 01b72aa477..3033b70615 100644 --- a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c +++ b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c @@ -98,8 +98,11 @@ static void clockHandler(void) #if (CLOCK_DRIVER_USE_FAST_IDLE == 1) do { rtems_clock_tick(); - } while ( _Thread_Executing == _Thread_Idle && - _Thread_Heir == _Thread_Executing); + } while ( + _Thread_Heir == _Thread_Executing + && _Thread_Executing->Start.entry_point + == rtems_configuration_get_idle_task() + ); #else rtems_clock_tick(); diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c index 4ee24710b3..5d1419cdb2 100644 --- a/cpukit/sapi/src/exinit.c +++ b/cpukit/sapi/src/exinit.c @@ -237,7 +237,7 @@ void rtems_initialize_start_multitasking(void) ******************************************************************* ******************************************************************* *******************************************************************/ - - status = _Per_CPU_Information[0].idle->Wait.return_code; + + status = _Thread_Get_global_exit_status(); rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, status ); } diff --git a/cpukit/sapi/src/exshutdown.c b/cpukit/sapi/src/exshutdown.c index 2b99995825..a54b1e6e86 100644 --- a/cpukit/sapi/src/exshutdown.c +++ b/cpukit/sapi/src/exshutdown.c @@ -44,8 +44,7 @@ void rtems_shutdown_executive( _SMP_Request_other_cores_to_shutdown(); #endif - _Per_CPU_Information[0].idle->Wait.return_code = result; - + _Thread_Set_global_exit_status( result ); _System_state_Set( SYSTEM_STATE_SHUTDOWN ); _Thread_Stop_multitasking(); diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h index 735b422c54..f545310e1c 100644 --- a/cpukit/score/include/rtems/score/percpu.h +++ b/cpukit/score/include/rtems/score/percpu.h @@ -162,9 +162,6 @@ typedef struct { /** This is the heir thread for this this CPU. */ Thread_Control *heir; - /** This is the idle thread for this CPU. */ - Thread_Control *idle; - /** This is the time of the last context switch on this CPU. */ Timestamp_Control time_of_last_context_switch; @@ -283,8 +280,6 @@ void _Per_CPU_Wait_for_state( _Per_CPU_Information[bsp_smp_processor_id()].heir #define _Thread_Executing \ _Per_CPU_Information[bsp_smp_processor_id()].executing -#define _Thread_Idle \ - _Per_CPU_Information[bsp_smp_processor_id()].idle #define _ISR_Nest_level \ _Per_CPU_Information[bsp_smp_processor_id()].isr_nest_level #define _CPU_Interrupt_stack_low \ diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl index 681cfcc3df..a42da1d5b8 100644 --- a/cpukit/score/inline/rtems/score/thread.inl +++ b/cpukit/score/inline/rtems/score/thread.inl @@ -344,6 +344,24 @@ RTEMS_INLINE_ROUTINE void _Thread_Internal_free ( _Objects_Free( &_Thread_Internal_information, &the_task->Object ); } +RTEMS_INLINE_ROUTINE void _Thread_Set_global_exit_status( + uint32_t exit_status +) +{ + Thread_Control *idle = (Thread_Control *) + _Thread_Internal_information.local_table[ 1 ]; + + idle->Wait.return_code = exit_status; +} + +RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_global_exit_status( void ) +{ + const Thread_Control *idle = (const Thread_Control *) + _Thread_Internal_information.local_table[ 1 ]; + + return idle->Wait.return_code; +} + /** * This routine returns the C library re-enterant pointer. */ diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c index a0279dec49..cc4282eed3 100644 --- a/cpukit/score/src/threadcreateidle.c +++ b/cpukit/score/src/threadcreateidle.c @@ -40,9 +40,11 @@ static inline void _Thread_Create_idle_helper( int cpu ) { - Objects_Name name; - Thread_Control *idle; + Per_CPU_Control *per_cpu; + Objects_Name name; + Thread_Control *idle; + per_cpu = &_Per_CPU_Information[ cpu ]; name.name_u32 = name_u32; /* @@ -79,9 +81,8 @@ static inline void _Thread_Create_idle_helper( * WARNING!!! This is necessary to "kick" start the system and * MUST be done before _Thread_Start is invoked. */ - _Per_CPU_Information[ cpu ].idle = - _Per_CPU_Information[ cpu ].heir = - _Per_CPU_Information[ cpu ].executing = idle; + per_cpu->heir = + per_cpu->executing = idle; _Thread_Start( idle, diff --git a/testsuites/sptests/spsimplesched02/init.c b/testsuites/sptests/spsimplesched02/init.c index 8b053b6917..d4faa7ad3d 100644 --- a/testsuites/sptests/spsimplesched02/init.c +++ b/testsuites/sptests/spsimplesched02/init.c @@ -21,6 +21,7 @@ void ObtainRelease(bool suspendIdle); /* * Keep the names and IDs in global variables so another task can use them. */ +rtems_id Idle_id; rtems_id Task_id[ 3 ]; /* array of task ids */ rtems_name Task_name[ 3 ]; /* array of task names */ rtems_name Semaphore_name[ 2 ]; @@ -48,7 +49,7 @@ void ObtainRelease( bool suspendIdle ) if (suspendIdle) { puts( "INIT - Suspend Idle Task"); - status = rtems_task_suspend( _Thread_Idle->Object.id ); + status = rtems_task_suspend( Idle_id ); directive_failed( status, "rtems_task_suspend idle" ); } @@ -62,7 +63,7 @@ void ObtainRelease( bool suspendIdle ) if (suspendIdle) { puts( "INIT - Resume Idle Task"); - status = rtems_task_resume( _Thread_Idle->Object.id ); + status = rtems_task_resume( Idle_id ); directive_failed( status, "rtems_task_resume idle" ); } } @@ -75,6 +76,14 @@ rtems_task Init( puts( "\n\n*** SIMPLE SCHEDULER 02 TEST ***" ); + status = _Objects_Name_to_id_u32( + &_Thread_Internal_information, + rtems_build_name( 'I', 'D', 'L', 'E' ), + RTEMS_SEARCH_LOCAL_NODE, + &Idle_id + ); + rtems_test_assert( status == RTEMS_SUCCESSFUL ); + /* * Create the semaphore. Then obtain and release the * semaphore with no other tasks running. -- cgit v1.2.3