Changeset 11b05f1 in rtems


Ignore:
Timestamp:
May 8, 2014, 8:11:13 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
89f0794
Parents:
35a3af7a
git-author:
Sebastian Huber <sebastian.huber@…> (05/08/14 08:11:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/08/14 11:02:40)
Message:

score: Fix CPU context usage on SMP

We must not alter the is executing indicator in
_CPU_Context_Initialize() since this would cause an invalid state during
a self restart.

The is executing indicator must be valid at creation time since
otherwise _Thread_Kill_zombies() uses an undefined value for not started
threads. This could result in a system life lock.

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/shared/irq_asm.S

    r35a3af7a r11b05f1  
    165165
    166166#if defined(RTEMS_SMP)
    167         ! Indicate that this context is no longer executing
     167        ! The executing context no longer executes on this processor
    168168        stb     %g0, [%o0 + SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
    169169
    170         ! Wait for context to stop execution if necessary
     170        ! Wait for heir context to stop execution
    1711711:
    172172        ldub    [%o1 + SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET], %g1
     
    175175         mov    1, %g1
    176176
    177         ! Indicate that this context is executing
     177        ! The heir context executes now on this processor
    178178        stb     %g1, [%o1 + SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
    179179#endif
  • c/src/lib/libcpu/powerpc/new-exceptions/cpu.c

    r35a3af7a r11b05f1  
    124124    msr_value &= ~PPC_MSR_FP;
    125125
    126   memset( the_context, 0, sizeof( *the_context ) );
    127 
    128126  the_ppc_context = ppc_get_context( the_context );
    129127  the_ppc_context->gpr1 = sp;
    130128  the_ppc_context->msr = msr_value;
    131129  the_ppc_context->lr = (uint32_t) entry_point;
    132 
    133 #ifdef RTEMS_SMP
    134   the_ppc_context->is_executing = false;
    135 #endif
    136130
    137131#ifdef __ALTIVEC__
  • c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S

    r35a3af7a r11b05f1  
    328328
    329329#ifdef RTEMS_SMP
    330         /* Indicate that this context is no longer executing */
     330        /* The executing context no longer executes on this processor */
    331331        msync
    332332        li      r5, 0
    333333        stb     r5, PPC_CONTEXT_OFFSET_IS_EXECUTING(r3)
    334 #endif
    335 
    336         /* Restore context from r4 */
    337 restore_context:
    338 
    339 #ifdef RTEMS_SMP
    340         /* Wait for context to stop execution if necessary */
     334
     335        /* Wait for heir context to stop execution */
    3413361:
    342337        lbz     r5, PPC_CONTEXT_OFFSET_IS_EXECUTING(r4)
     
    344339        bne     1b
    345340
    346         /* Indicate that this context is executing */
     341        /* The heir context executes now on this processor */
    347342        li      r5, 1
    348343        stb     r5, PPC_CONTEXT_OFFSET_IS_EXECUTING(r4)
    349344        isync
    350345#endif
     346
     347        /* Restore context from r4 */
     348restore_context:
    351349
    352350#ifdef __ALTIVEC__
  • cpukit/score/cpu/arm/cpu.c

    r35a3af7a r11b05f1  
    102102#endif
    103103
    104 #ifdef RTEMS_SMP
    105   the_context->is_executing = false;
    106 #endif
    107 
    108104  if ( tls_area != NULL ) {
    109105    _TLS_TCB_at_area_begin_initialize( tls_area );
  • cpukit/score/cpu/arm/cpu_asm.S

    r35a3af7a r11b05f1  
    6969
    7070#ifdef RTEMS_SMP
    71         /* Indicate that this context is no longer executing */
     71        /* The executing context no longer executes on this processor */
    7272        dmb
    7373        mov     r3, #0
    7474        strb    r3, [r0, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
     75
     76        /* Wait for heir context to stop execution */
     771:
     78        ldrb    r3, [r1, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
     79        cmp     r3, #0
     80        bne     1b
     81
     82        /* The heir context executes now on this processor */
     83        dmb
     84        mov     r3, #1
     85        strb    r3, [r1, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
    7586#endif
    7687
     
    7990#ifdef ARM_MULTILIB_HAS_LOAD_STORE_EXCLUSIVE
    8091        clrex
    81 #endif
    82 
    83 #ifdef RTEMS_SMP
    84         /* Wait for context to stop execution if necessary */
    85 1:
    86         ldrb    r3, [r1, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
    87         cmp     r3, #0
    88         bne     1b
    89 
    90         /* Indicate that this context is executing */
    91         dmb
    92         mov     r3, #1
    93         strb    r3, [r1, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
    9492#endif
    9593
  • cpukit/score/cpu/arm/rtems/score/cpu.h

    r35a3af7a r11b05f1  
    423423
    424424#ifdef RTEMS_SMP
    425   #define _CPU_Context_Get_is_executing( _context ) \
    426     (_context)->is_executing
     425  static inline bool _CPU_Context_Get_is_executing(
     426    const Context_Control *context
     427  )
     428  {
     429    return context->is_executing;
     430  }
     431
     432  static inline void _CPU_Context_Set_is_executing(
     433    Context_Control *context,
     434    bool is_executing
     435  )
     436  {
     437    context->is_executing = is_executing;
     438  }
    427439#endif
    428440
  • cpukit/score/cpu/i386/cpu_asm.S

    r35a3af7a r11b05f1  
    5959
    6060#ifdef RTEMS_SMP
    61         /* Indicate that this context is no longer executing */
     61        /* The executing context no longer executes on this processor */
    6262        movb      $0, I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET(eax)
    6363#endif
     
    6565        movl      HEIRCONTEXT_ARG(esp),eax /* eax = heir threads context */
    6666
    67 restore:
    6867#ifdef RTEMS_SMP
    69         /* Wait for context to stop execution if necessary */
     68        /* Wait for heir context to stop execution */
    70691:
    7170        movb      I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET(eax), bl
     
    7372        jne       1b
    7473
    75         /* Indicate that this context is executing */
     74        /* The heir context executes now on this processor */
    7675        movb      $1, I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET(eax)
    7776#endif
    7877
     78restore:
    7979        pushl     REG_EFLAGS(eax)          /* push eflags */
    8080        popf                               /* restore eflags */
  • cpukit/score/cpu/i386/rtems/score/cpu.h

    r35a3af7a r11b05f1  
    168168
    169169#ifdef RTEMS_SMP
    170   #define _CPU_Context_Get_is_executing( _context ) \
    171     (_context)->is_executing
     170  static inline bool _CPU_Context_Get_is_executing(
     171    const Context_Control *context
     172  )
     173  {
     174    return context->is_executing;
     175  }
     176
     177  static inline void _CPU_Context_Set_is_executing(
     178    Context_Control *context,
     179    bool is_executing
     180  )
     181  {
     182    context->is_executing = is_executing;
     183  }
    172184#endif
    173185
     
    455467
    456468
    457 #ifdef RTEMS_SMP
    458   #define _I386_Context_Initialize_is_executing( _the_context ) \
    459     (_the_context)->is_executing = false
    460 #else
    461   #define _I386_Context_Initialize_is_executing( _the_context )
    462 #endif
    463469
    464470#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
     
    476482    (_the_context)->ebp     = (void *) 0; \
    477483    (_the_context)->esp     = (void *) _stack; \
    478     _I386_Context_Initialize_is_executing( _the_context ); \
    479484  } while (0)
    480485
  • cpukit/score/cpu/no_cpu/rtems/score/cpu.h

    r35a3af7a r11b05f1  
    15971597
    15981598  /**
    1599    * @brief Macro to return the is executing field of the thread context.
     1599   * @brief Gets the is executing indicator of the thread context.
     1600   *
     1601   * @param[in] context The context.
    16001602   */
    1601   #define _CPU_Context_Get_is_executing( _context ) \
    1602     ( ( _context )->is_executing )
     1603  static inline bool _CPU_Context_Get_is_executing(
     1604    const Context_Control *context
     1605  )
     1606  {
     1607    return context->is_executing;
     1608  }
     1609
     1610  /**
     1611   * @brief Sets the is executing indicator of the thread context.
     1612   *
     1613   * @param[in] context The context.
     1614   * @param[in] is_executing The new value for the is executing indicator.
     1615   */
     1616  static inline void _CPU_Context_Set_is_executing(
     1617    Context_Control *context,
     1618    bool is_executing
     1619  )
     1620  {
     1621    context->is_executing = is_executing;
     1622  }
    16031623#endif
    16041624
  • cpukit/score/cpu/powerpc/rtems/score/cpu.h

    r35a3af7a r11b05f1  
    344344
    345345#ifdef RTEMS_SMP
    346   #define _CPU_Context_Get_is_executing( _context ) \
    347     ppc_get_context(_context)->is_executing
     346  static inline bool _CPU_Context_Get_is_executing(
     347    const Context_Control *context
     348  )
     349  {
     350    return ppc_get_context(context)->is_executing;
     351  }
     352
     353  static inline void _CPU_Context_Set_is_executing(
     354    Context_Control *context,
     355    bool is_executing
     356  )
     357  {
     358    ppc_get_context(context)->is_executing = is_executing;
     359  }
    348360#endif
    349361#endif /* ASM */
  • cpukit/score/cpu/sparc/cpu.c

    r35a3af7a r11b05f1  
    331331    the_context->isr_dispatch_disable = 0;
    332332
    333 #if defined(RTEMS_SMP)
    334   the_context->is_executing = false;
    335 #endif
    336 
    337333  if ( tls_area != NULL ) {
    338334    void *tcb = _TLS_TCB_after_TLS_block_initialize( tls_area );
  • cpukit/score/cpu/sparc/rtems/score/cpu.h

    r35a3af7a r11b05f1  
    489489
    490490#ifdef RTEMS_SMP
    491   #define _CPU_Context_Get_is_executing( _context ) \
    492     (_context)->is_executing
     491  static inline bool _CPU_Context_Get_is_executing(
     492    const Context_Control *context
     493  )
     494  {
     495    return context->is_executing;
     496  }
     497
     498  static inline void _CPU_Context_Set_is_executing(
     499    Context_Control *context,
     500    bool is_executing
     501  )
     502  {
     503    context->is_executing = is_executing;
     504  }
    493505#endif
    494506
  • cpukit/score/src/threadinitialize.c

    r35a3af7a r11b05f1  
    185185  the_thread->is_in_the_air           = false;
    186186  the_thread->scheduler               = scheduler;
     187  _CPU_Context_Set_is_executing( &the_thread->Registers, false );
    187188#endif
    188189
  • testsuites/sptests/spcontext01/init.c

    r35a3af7a r11b05f1  
    161161}
    162162
     163static void test_context_is_executing(void)
     164{
     165#if defined(RTEMS_SMP)
     166  Context_Control context;
     167  bool is_executing;
     168
     169  memset(&context, 0, sizeof(context));
     170
     171  is_executing = _CPU_Context_Get_is_executing(&context);
     172  rtems_test_assert(!is_executing);
     173
     174  _CPU_Context_Set_is_executing(&context, true);
     175  is_executing = _CPU_Context_Get_is_executing(&context);
     176  rtems_test_assert(is_executing);
     177
     178  _CPU_Context_Set_is_executing(&context, false);
     179  is_executing = _CPU_Context_Get_is_executing(&context);
     180  rtems_test_assert(!is_executing);
     181
     182  _CPU_Context_Set_is_executing(&context, true);
     183  _CPU_Context_Initialize(&context, NULL, 0, 0, NULL, false, NULL);
     184  is_executing = _CPU_Context_Get_is_executing(&context);
     185  rtems_test_assert(is_executing);
     186#endif
     187}
     188
    163189static void Init(rtems_task_argument arg)
    164190{
     
    167193  TEST_BEGIN();
    168194
     195  test_context_is_executing();
    169196  test(self);
    170197
Note: See TracChangeset for help on using the changeset viewer.