Changeset d7c3883 in rtems


Ignore:
Timestamp:
Apr 21, 2011, 7:05:15 PM (8 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.11, master
Children:
1c95d94
Parents:
85f5c14b
Message:

2011-04-21 Jennifer Averett <Jennifer.Averett@…

PR 1777/cpukit

  • libcsupport/src/malloc_deferred.c, libcsupport/src/realloc.c, score/Makefile.am, score/cpu/lm32/irq.c, score/cpu/nios2/irq.c, score/include/rtems/score/coremutex.h, score/include/rtems/score/thread.h, score/inline/rtems/score/thread.inl, score/src/heapfree.c, score/src/pheapwalk.c, score/src/smp.c, score/src/threaddispatch.c: Consolidated access to _Thread_Dispatch_disable_level.
  • score/src/threaddisabledispatch.c, score/src/threadenabledispatch.c: New files.
Location:
cpukit
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r85f5c14b rd7c3883  
     12011-04-21      Jennifer Averett <Jennifer.Averett@OARcorp.com
     2
     3        PR 1777/cpukit
     4        * libcsupport/src/malloc_deferred.c, libcsupport/src/realloc.c,
     5        score/Makefile.am, score/cpu/lm32/irq.c, score/cpu/nios2/irq.c,
     6        score/include/rtems/score/coremutex.h,
     7        score/include/rtems/score/thread.h,
     8        score/inline/rtems/score/thread.inl, score/src/heapfree.c,
     9        score/src/pheapwalk.c, score/src/smp.c, score/src/threaddispatch.c:
     10        Consolidated access to _Thread_Dispatch_disable_level.
     11        * score/src/threaddisabledispatch.c, score/src/threadenabledispatch.c:
     12        New files.
     13
    1142011-04-18      Joel Sherrill <joel.sherrilL@OARcorp.com>
    215
  • cpukit/libcsupport/src/malloc_deferred.c

    r85f5c14b rd7c3883  
    2727bool malloc_is_system_state_OK(void)
    2828{
    29   if ( _Thread_Dispatch_disable_level > 0 )
     29  if ( _Thread_Dispatch_in_critical_section() )
    3030    return false;
    3131
  • cpukit/libcsupport/src/realloc.c

    r85f5c14b rd7c3883  
    3636
    3737  if (_System_state_Is_up(_System_state_Get())) {
    38     if (_Thread_Dispatch_disable_level > 0)
     38    if (_Thread_Dispatch_in_critical_section())
    3939      return (void *) 0;
    4040
  • cpukit/score/Makefile.am

    r85f5c14b rd7c3883  
    190190    src/threadclearstate.c src/threadclose.c src/threadcreateidle.c \
    191191    src/threaddelayended.c src/threaddispatch.c \
     192    src/threadenabledispatch.c src/threaddisabledispatch.c \
    192193    src/threadget.c src/threadhandler.c src/threadinitialize.c \
    193194    src/threadloadenv.c src/threadready.c src/threadreset.c \
  • cpukit/score/cpu/lm32/irq.c

    r85f5c14b rd7c3883  
    4545  /* Interrupts are disabled upon entry to this Handler */
    4646
    47   _Thread_Dispatch_disable_level++;
     47  _Thread_Dispatch_increment_disable_level();
    4848
    4949#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
     
    7272#endif
    7373
    74   _Thread_Dispatch_disable_level--;
     74  _Thread_Dispatch_decrement_disable_level();
    7575
    7676  _CPU_ISR_Enable( level );
  • cpukit/score/cpu/nios2/irq.c

    r85f5c14b rd7c3883  
    5151  _ISR_Nest_level++;
    5252
    53   _Thread_Dispatch_disable_level++;
     53  _Thread_Dispatch_increment_disable_level();
    5454
    5555  if ( _ISR_Vector_table[ vector] )
     
    6161  _CPU_ISR_Disable( level );
    6262
    63   _Thread_Dispatch_disable_level--;
     63  _Thread_Dispatch_decrement_disable_level();
    6464
    6565  _ISR_Nest_level--;
     
    7070#endif
    7171
    72     if( _Thread_Dispatch_disable_level == 0 )
     72    if( !_Thread_Dispatch_in_critical_section() )
    7373    {
    7474      if ( _Thread_Dispatch_necessary ) {
  • cpukit/score/include/rtems/score/coremutex.h

    r85f5c14b rd7c3883  
    369369  _the_mutex, _id, _wait, _timeout, _level ) \
    370370  do { \
    371     if ( _Thread_Dispatch_disable_level \
     371    if ( _Thread_Dispatch_in_critical_section() \
    372372        && (_wait) \
    373373        && (_System_state_Get() >= SYSTEM_STATE_BEGIN_MULTITASKING ) \
  • cpukit/score/include/rtems/score/thread.h

    r85f5c14b rd7c3883  
    4545#if defined(RTEMS_POSIX_API)
    4646  #define RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API
     47#endif
     48
     49#if defined(RTEMS_SMP) || \
     50    defined(RTEMS_HEAVY_STACK_DEBUG) || \
     51    defined(RTEMS_HEAVY_MALLOC_DEBUG)
     52  #define __THREAD_DO_NOT_INLINE_DISABLE_DISPATCH__
     53#endif
     54
     55#if defined(RTEMS_SMP) || \
     56   (CPU_INLINE_ENABLE_DISPATCH == FALSE) || \
     57   (__RTEMS_DO_NOT_INLINE_THREAD_ENABLE_DISPATCH__ == 1)
     58  #define __THREAD_DO_NOT_INLINE_ENABLE_DISPATCH__
    4759#endif
    4860
  • cpukit/score/inline/rtems/score/thread.inl

    r85f5c14b rd7c3883  
    3131 *  @{
    3232 */
     33
     34/**
     35 * This routine returns true if thread dispatch indicates
     36 * that we are in a critical section.
     37 */
     38RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_in_critical_section(void)
     39{
     40   if (  _Thread_Dispatch_disable_level == 0 )
     41    return false;
     42
     43   return true;
     44}
     45
     46/**
     47 * This routine returns value of the the thread dispatch level.
     48 */
     49RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_get_disable_level(void)
     50{
     51  return _Thread_Dispatch_disable_level;
     52}
     53
     54/**
     55 * This routine sets thread dispatch level to the
     56 * value passed in.
     57 */
     58RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_set_disable_level(uint32_t value)
     59{
     60  _Thread_Dispatch_disable_level = value;
     61  return value;
     62}
     63
     64/**
     65 * This rountine increments the thread dispatch level
     66 */
     67RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_increment_disable_level(void)
     68{
     69  _Thread_Dispatch_disable_level++;
     70  return _Thread_Dispatch_disable_level;
     71}
     72
     73/**
     74 * This routine decrements the thread dispatch level.
     75 */
     76RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_decrement_disable_level(void)
     77{
     78  _Thread_Dispatch_disable_level--;
     79  return _Thread_Dispatch_disable_level;
     80}
     81
     82/**
     83 *  This routine initializes the thread dispatching subsystem.
     84 */
     85
     86RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void )
     87{
     88  _Thread_Dispatch_set_disable_level( 1 );
     89}
     90
    3391
    3492/**
     
    151209 */
    152210
    153 #if defined(RTEMS_HEAVY_STACK_DEBUG) || defined(RTEMS_HEAVY_MALLOC_DEBUG)
    154   #include <rtems/bspIo.h>
    155   #include <rtems/fatal.h>
    156   #include <rtems/stackchk.h>
    157   #include <rtems/score/sysstate.h>
    158   #include <rtems/score/heap.h>
    159 
    160   /*
    161    * This is currently not defined in any .h file, so we have to
    162    * extern it here.
    163    */
    164   extern Heap_Control  *RTEMS_Malloc_Heap;
    165 #endif
    166 
     211#if defined ( __THREAD_DO_NOT_INLINE_DISABLE_DISPATCH__ )
     212void _Thread_Disable_dispatch( void );
     213#else
    167214RTEMS_INLINE_ROUTINE void _Thread_Disable_dispatch( void )
    168215{
    169   /*
    170    *  This check is very brutal to system performance but is very helpful
    171    *  at finding blown stack problems.  If you have a stack problem and
    172    *  need help finding it, then uncomment this code.  Every system
    173    *  call will check the stack and since mutexes are used frequently
    174    *  in most systems, you might get lucky.
    175    */
    176   #if defined(RTEMS_HEAVY_STACK_DEBUG)
    177     if (_System_state_Is_up(_System_state_Get()) && (_ISR_Nest_level == 0)) {
    178       if ( rtems_stack_checker_is_blown() ) {
    179         printk( "Stack blown!!\n" );
    180         rtems_fatal_error_occurred( 99 );
    181       }
    182     }
    183   #endif
    184 
    185   _Thread_Dispatch_disable_level += 1;
     216  _Thread_Dispatch_increment_disable_level();
    186217  RTEMS_COMPILER_MEMORY_BARRIER();
    187 
    188   /*
    189    * This check is even more brutal than the other one.  This enables
    190    * malloc heap integrity checking upon entry to every system call.
    191    */
    192   #if defined(RTEMS_HEAVY_MALLOC_DEBUG)
    193     if ( _Thread_Dispatch_disable_level == 1 ) {
    194       _Heap_Walk( RTEMS_Malloc_Heap,99, false );
    195     }
    196   #endif
    197 }
     218}
     219#endif
    198220
    199221/**
     
    204226 */
    205227
    206 #if ( (defined(CPU_INLINE_ENABLE_DISPATCH) && \
    207        (CPU_INLINE_ENABLE_DISPATCH == FALSE)) || \
    208       (__RTEMS_DO_NOT_INLINE_THREAD_ENABLE_DISPATCH__ == 1) )
    209 void _Thread_Enable_dispatch( void );
     228#if defined ( __THREAD_DO_NOT_INLINE_ENABLE_DISPATCH__ )
     229  void _Thread_Enable_dispatch( void );
    210230#else
    211 /* inlining of enable dispatching must be true */
    212 RTEMS_INLINE_ROUTINE void _Thread_Enable_dispatch( void )
    213 {
    214   RTEMS_COMPILER_MEMORY_BARRIER();
    215   if ( (--_Thread_Dispatch_disable_level) == 0 )
    216     _Thread_Dispatch();
    217 }
    218 #endif
    219 
     231  /* inlining of enable dispatching must be true */
     232  RTEMS_INLINE_ROUTINE void _Thread_Enable_dispatch( void )
     233  {
     234    RTEMS_COMPILER_MEMORY_BARRIER();
     235    if ( _Thread_Dispatch_decrement_disable_level() == 0 )
     236      _Thread_Dispatch();
     237  }
     238#endif
    220239
    221240/**
     
    228247{
    229248  RTEMS_COMPILER_MEMORY_BARRIER();
    230   _Thread_Dispatch_disable_level -= 1;
     249  _Thread_Dispatch_decrement_disable_level();
    231250}
    232251
     
    238257RTEMS_INLINE_ROUTINE bool _Thread_Is_dispatching_enabled( void )
    239258{
    240   return ( _Thread_Dispatch_disable_level == 0 );
     259  return  ( _Thread_Dispatch_in_critical_section() == false );
    241260}
    242261
     
    249268{
    250269  return ( _Thread_Dispatch_necessary );
    251 }
    252 
    253 /**
    254  *  This routine initializes the thread dispatching subsystem.
    255  */
    256 
    257 RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void )
    258 {
    259   _Thread_Dispatch_disable_level = 1;
    260270}
    261271
  • cpukit/score/src/heapfree.c

    r85f5c14b rd7c3883  
    9090     * disable level is a way to detect this use case.
    9191     */
    92     if ( _Thread_Dispatch_disable_level == 0 ) {
     92    if ( !_Thread_Dispatch_in_critical_section() ) {
    9393      Heap_Block *const next = block->Protection_begin.next_delayed_free_block;
    9494      if ( next == NULL ) {
  • cpukit/score/src/pheapwalk.c

    r85f5c14b rd7c3883  
    4040   * NOTE: Dispatching is also disabled during initialization.
    4141   */
    42   if ( !_Thread_Dispatch_disable_level ) {
     42  if ( _Thread_Dispatch_in_critical_section() == false ) {
    4343    _RTEMS_Lock_allocator();
    4444      status = _Heap_Walk( the_heap, source, do_dump );
  • cpukit/score/src/smp.c

    r85f5c14b rd7c3883  
    3838   *  is only one executing and heir right now, we have to fake this out.
    3939   */
    40   _Thread_Dispatch_disable_level = 1;
     40  _Thread_Dispatch_set_disable_level(1);
    4141  _Thread_Executing = heir;
    4242  _CPU_Context_switch_to_first_task_smp( &heir->Registers );
     
    104104  if ( message & RTEMS_BSP_SMP_SHUTDOWN ) {
    105105    ISR_Level level;
    106     _Thread_Dispatch_disable_level = 0;
     106    _Thread_Dispatch_set_disable_level(0);
    107107    _Per_CPU_Information[cpu].isr_nest_level = 0;
    108108    _Per_CPU_Information[cpu].state = RTEMS_BSP_SMP_CPU_SHUTDOWN;
  • cpukit/score/src/threaddispatch.c

    r85f5c14b rd7c3883  
    11/*
    22 *  Thread Handler
    3  *
    43 *
    54 *  COPYRIGHT (c) 1989-2009.
     
    3534#endif
    3635
    37 /*PAGE
    38  *
    39  *  _Thread_Enable_dispatch
    40  *
    41  *  This kernel routine exits a context switch disable critical section.
    42  *  This is the NOT INLINED version.
    43  *
    44  *  Input parameters:  NONE
    45  *
    46  *  Output parameters:  NONE
    47  *
    48  *  INTERRUPT LATENCY:
    49  *    dispatch thread
    50  *    no dispatch thread
    51  */
    52 
    53 #if ( (defined(CPU_INLINE_ENABLE_DISPATCH) &&  \
    54        (CPU_INLINE_ENABLE_DISPATCH == FALSE)) || \
    55       (__RTEMS_DO_NOT_INLINE_THREAD_ENABLE_DISPATCH__ == 1) )
    56 void _Thread_Enable_dispatch( void )
    57 {
    58   if ( --_Thread_Dispatch_disable_level )
    59     return;
    60   _Thread_Dispatch();
    61 }
    62 #endif
    63 
    64 /*PAGE
    65  *
     36/**
    6637 *  _Thread_Dispatch
    6738 *
     
    7243 *  ALTERNATE ENTRY POINTS:
    7344 *    void _Thread_Enable_dispatch();
    74  *
    75  *  Input parameters:  NONE
    76  *
    77  *  Output parameters:  NONE
    7845 *
    7946 *  INTERRUPT LATENCY:
     
    9259  while ( _Thread_Dispatch_necessary == true ) {
    9360    heir = _Thread_Heir;
    94     _Thread_Dispatch_disable_level = 1;
     61   _Thread_Dispatch_set_disable_level( 1 );
    9562    _Thread_Dispatch_necessary = false;
    9663    _Thread_Executing = heir;
     
    186153
    187154post_switch:
    188   _Thread_Dispatch_disable_level = 0;
     155  _Thread_Dispatch_set_disable_level( 0 );
    189156
    190157  _ISR_Enable( level );
Note: See TracChangeset for help on using the changeset viewer.