diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-18 13:40:39 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-06 09:43:57 +0100 |
commit | 7336be9d78266adfb540170e5105caf8eb003d2f (patch) | |
tree | 5dc7ab7a5c3c33c7e007a8e8e48cb1167187b0ca /cpukit/score/src/smp.c | |
parent | bsp/leon3: Unmask IPI only on secondary processor (diff) | |
download | rtems-7336be9d78266adfb540170e5105caf8eb003d2f.tar.bz2 |
score: SMP initialization and shutdown changes
Rename _SMP_Request_other_cores_to_perform_first_context_switch() into
_SMP_Request_start_multitasking() since this requests now a multitasking
start on all configured and available processors. The name corresponds
_Thread_Start_multitasking() and
_SMP_Start_multitasking_on_secondary_processor() actions issued in
response to this request. Move in source file to right place.
Rename PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING into
PER_CPU_STATE_READY_TO_START_MULTITASKING.
Rename PER_CPU_STATE_BEGIN_MULTITASKING into
PER_CPU_STATE_REQUEST_START_MULTITASKING.
Rename _SMP_Request_other_cores_to_shutdown() into
_SMP_Request_shutdown().
Add a per-CPU state lock to protect all changes. This was necessary to
offer a controlled shutdown of the system (atomic read/writes alone are
not sufficient for this kind of synchronization).
Add documentation for Per_CPU_State.
Delete debug output.
New tests smptests/smpfatal01 and smptests/smpfatal02.
Diffstat (limited to 'cpukit/score/src/smp.c')
-rw-r--r-- | cpukit/score/src/smp.c | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c index 59036eb466..0f632236b7 100644 --- a/cpukit/score/src/smp.c +++ b/cpukit/score/src/smp.c @@ -24,10 +24,6 @@ #include <rtems/score/threadimpl.h> #include <rtems/config.h> -#if defined(RTEMS_DEBUG) - #include <rtems/bspIo.h> -#endif - void _SMP_Handler_initialize( void ) { uint32_t max_cpus = rtems_configuration_get_maximum_processors(); @@ -47,21 +43,38 @@ void _SMP_Handler_initialize( void ) _SMP_Processor_count = max_cpus; } -void _SMP_Start_multitasking_on_secondary_processor( void ) +void _SMP_Request_start_multitasking( void ) { Per_CPU_Control *self_cpu = _Per_CPU_Get(); + uint32_t ncpus = _SMP_Get_processor_count(); + uint32_t cpu; + + _Per_CPU_State_change( self_cpu, PER_CPU_STATE_READY_TO_START_MULTITASKING ); - #if defined(RTEMS_DEBUG) - printk( "Made it to %d -- ", _Per_CPU_Get_index( self_cpu ) ); - #endif + for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { + Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); + + _Per_CPU_State_change( per_cpu, PER_CPU_STATE_REQUEST_START_MULTITASKING ); + } +} - _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING ); +void _SMP_Start_multitasking_on_secondary_processor( void ) +{ + Per_CPU_Control *self_cpu = _Per_CPU_Get(); - _Per_CPU_Wait_for_state( self_cpu, PER_CPU_STATE_BEGIN_MULTITASKING ); + _Per_CPU_State_change( self_cpu, PER_CPU_STATE_READY_TO_START_MULTITASKING ); _Thread_Start_multitasking(); } +void _SMP_Request_shutdown( void ) +{ + uint32_t self = _SMP_Get_current_processor(); + Per_CPU_Control *self_cpu = _Per_CPU_Get_by_index( self ); + + _Per_CPU_State_change( self_cpu, PER_CPU_STATE_SHUTDOWN ); +} + void _SMP_Send_message( uint32_t cpu, uint32_t message ) { Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); @@ -88,47 +101,3 @@ void _SMP_Broadcast_message( uint32_t message ) } } } - -void _SMP_Request_other_cores_to_perform_first_context_switch( void ) -{ - uint32_t self = _SMP_Get_current_processor(); - uint32_t ncpus = _SMP_Get_processor_count(); - uint32_t cpu; - - for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { - Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); - - if ( cpu != self ) { - _Per_CPU_Wait_for_state( - per_cpu, - PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING - ); - - _Per_CPU_Change_state( per_cpu, PER_CPU_STATE_BEGIN_MULTITASKING ); - } - } -} - -void _SMP_Request_other_cores_to_shutdown( void ) -{ - uint32_t self = _SMP_Get_current_processor(); - - /* - * Do not use _SMP_Get_processor_count() since this value might be not - * initialized yet. For example due to a fatal error in the middle of - * _CPU_SMP_Initialize(). - */ - uint32_t ncpus = rtems_configuration_get_maximum_processors(); - - uint32_t cpu; - - for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { - if ( cpu != self ) { - const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); - - if ( per_cpu->state != PER_CPU_STATE_BEFORE_INITIALIZATION ) { - _SMP_Send_message( cpu, SMP_MESSAGE_SHUTDOWN ); - } - } - } -} |