SMP boot sequence

Sebastian Huber sebastian.huber at
Fri Oct 25 12:40:08 UTC 2013

On 2013-10-25 14:23, Daniel Hellstrom wrote:
>> Interrupts are enabled in _Thread_Handler() the first time.
>>> However on a SMP machine the secondary CPUs have enabled global
>>> CPU interrupt in order to receive IPIs during the boot sequence.
>> This is a bug.  Interrupts must be disabled during the low-level boot
>> process.  Only _Thread_Handler() should enable the interrupts. However the
>> secondary processors must be able to notice an IPI and serve it right after
>> the interrupts are enabled the first time.
> Interrupts are off on CPU0 during boot.
> I'm not sure I follow this 100%. During low-level boot interrupt should be off
> on all CPUs, _Thread_Handler() enables the current CPU's interrupt.

Yes, interrupts must be disabled on all CPUs during low-level start.

> So how
> should a secondary core receive an IPI, I mean an IPI is required to get to
> _Thread_Handler() in order to turn on interrupts.

No, this is not the case.  Secondary cores busy wait for a per CPU state change:

void rtems_smp_secondary_cpu_initialize( void )
   Per_CPU_Control *self_cpu = _Per_CPU_Get();

   #if defined(RTEMS_DEBUG)
     printk( "Made it to %d -- ", _Per_CPU_Get_index( self_cpu ) );

   _Per_CPU_Change_state( self_cpu, PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING );

   _Per_CPU_Wait_for_state( self_cpu, PER_CPU_STATE_BEGIN_MULTITASKING );

   _Thread_Start_multitasking( NULL );

The previous RTEMS SMP support required an IPI to start multitasking on 
secondary processors, but this was a broken concept.

> But we need interrupts
> enabled in order for IPIs to work?
> Or are you saying that there is an endless loop waiting for CPU0 to signal
> multitasking via shared memory (not through IPI)? In that case I could just
> turn of secondary CPU interrupt.

Yes, exactly.

However, if you send an IPI from CPU0 to CPU1 and interrupts are disabled on 
CPU1, then once CPU1 enables interrupts this IPI must be serviced.

Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

More information about the devel mailing list