--- cpukit/score/include/rtems/score/threaddispatch.h | 12 ++++++++++++ cpukit/score/src/smp.c | 8 ++++++++ cpukit/score/src/threaddispatchdisablelevel.c | 13 +++++++++++++ 3 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/cpukit/score/include/rtems/score/threaddispatch.h b/cpukit/score/include/rtems/score/threaddispatch.h index 2211662..4c2ecb0 100644 --- a/cpukit/score/include/rtems/score/threaddispatch.h +++ b/cpukit/score/include/rtems/score/threaddispatch.h @@ -109,6 +109,18 @@ RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void ) void _Giant_Release( void ); /** + * @brief Releases the giant lock completely if held by the executing processor. + * + * The thread dispatch disable level is not altered by this function. + * + * The only use case for this operation is in + * _SMP_Request_processors_to_shutdown(). + * + * @param[in] self_cpu The current processor index. + */ + void _Giant_Drop( uint32_t self_cpu ); + + /** * @brief Sets thread dispatch level to the value passed in. * * This routine sets thread dispatch level to the diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c index 445a56a..41787e3 100644 --- a/cpukit/score/src/smp.c +++ b/cpukit/score/src/smp.c @@ -115,6 +115,14 @@ void _SMP_Request_processors_to_shutdown( void ) _Per_CPU_Change_state( per_cpu, PER_CPU_STATE_SHUTDOWN ); } } + + /* + * We have to drop the Giant lock here in order to give other processors the + * opportunity to receive the inter-processor interrupts issued previously. + * In case the executing thread still holds SMP locks, then other processors + * already waiting for this SMP lock will spin forever. + */ + _Giant_Drop( self ); } void _SMP_Send_message( uint32_t cpu, uint32_t message ) diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c index a3dec99..ec5ac81 100644 --- a/cpukit/score/src/threaddispatchdisablelevel.c +++ b/cpukit/score/src/threaddispatchdisablelevel.c @@ -57,6 +57,19 @@ static void _Giant_Do_release( void ) } } +void _Giant_Drop( uint32_t self_cpu ) +{ + Giant_Control *giant = &_Giant; + + _Assert( _ISR_Get_level() != 0 ); + + if ( giant->owner_cpu == self_cpu ) { + giant->nest_level = 0; + giant->owner_cpu = NO_OWNER_CPU; + _SMP_lock_Release( &giant->lock ); + } +} + uint32_t _Thread_Dispatch_increment_disable_level( void ) { ISR_Level isr_level; -- 1.7.7 _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel