Changeset 105b4e6 in rtems


Ignore:
Timestamp:
May 10, 2016, 4:47:19 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
4d76300a
Parents:
6e4f929
git-author:
Sebastian Huber <sebastian.huber@…> (05/10/16 04:47:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/12/16 11:24:40)
Message:

rtems: Use thread state lock for signals

Location:
cpukit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/asr.h

    r6e4f929 r105b4e6  
    2323#define _RTEMS_RTEMS_ASR_H
    2424
    25 #include <rtems/score/isrlock.h>
    2625#include <rtems/rtems/modes.h>
    2726
     
    7675  /** This field indicates if nest level of signals being processed */
    7776  uint32_t          nest_level;
    78   /** Lock to protect this structure */
    79   ISR_LOCK_MEMBER(  Lock )
    8077}   ASR_Information;
    8178
  • cpukit/rtems/include/rtems/rtems/asrimpl.h

    r6e4f929 r105b4e6  
    1919
    2020#include <rtems/rtems/asr.h>
     21
     22#include <string.h>
    2123
    2224#ifdef __cplusplus
     
    4143)
    4244{
    43   asr->is_enabled      = false;
    44   asr->handler         = NULL;
    45   asr->mode_set        = RTEMS_DEFAULT_MODES;
    46   asr->signals_posted  = 0;
    47   asr->signals_pending = 0;
    48   asr->nest_level      = 0;
    49 }
    50 
    51 RTEMS_INLINE_ROUTINE void _ASR_Create( ASR_Information *asr )
    52 {
    53   _ISR_lock_Initialize( &asr->Lock, "ASR" );
    54   RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );
    55 }
    56 
    57 RTEMS_INLINE_ROUTINE void _ASR_Destroy( ASR_Information *asr )
    58 {
    59   _ISR_lock_Destroy( &asr->Lock );
    60 }
    61 
    62 RTEMS_INLINE_ROUTINE void _ASR_Acquire_critical(
    63   ASR_Information  *asr,
    64   ISR_lock_Context *lock_context
    65 )
    66 {
    67   _ISR_lock_Acquire( &asr->Lock, lock_context );
    68 }
    69 
    70 RTEMS_INLINE_ROUTINE void _ASR_Acquire(
    71   ASR_Information  *asr,
    72   ISR_lock_Context *lock_context
    73 )
    74 {
    75   _ISR_lock_ISR_disable( lock_context );
    76   _ASR_Acquire_critical( asr, lock_context );
    77 }
    78 
    79 RTEMS_INLINE_ROUTINE void _ASR_Release(
    80   ASR_Information  *asr,
    81   ISR_lock_Context *lock_context
    82 )
    83 {
    84   _ISR_lock_Release_and_ISR_enable( &asr->Lock, lock_context );
     45  memset(asr, 0, sizeof(*asr));
    8546}
    8647
     
    10162{
    10263  rtems_signal_set new_signals_posted;
    103   ISR_lock_Context lock_context;
    10464
    105   _ASR_Acquire( asr, &lock_context );
    106     new_signals_posted   = asr->signals_pending;
    107     asr->signals_pending = asr->signals_posted;
    108     asr->signals_posted  = new_signals_posted;
    109   _ASR_Release( asr, &lock_context );
     65  new_signals_posted   = asr->signals_pending;
     66  asr->signals_pending = asr->signals_posted;
     67  asr->signals_posted  = new_signals_posted;
    11068
    11169  return new_signals_posted;
     
    12583{
    12684  rtems_signal_set signal_set;
    127   ISR_lock_Context lock_context;
    12885
    129   _ASR_Acquire( asr, &lock_context );
    130     signal_set = asr->signals_posted;
    131     asr->signals_posted = 0;
    132   _ASR_Release( asr, &lock_context );
     86  signal_set = asr->signals_posted;
     87  asr->signals_posted = 0;
    13388
    13489  return signal_set;
  • cpukit/rtems/src/signalcatch.c

    r6e4f929 r105b4e6  
    2626#include <rtems/score/threadimpl.h>
    2727
     28RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );
     29
    2830void _Signal_Action_handler(
    2931  Thread_Control   *executing,
     
    3840
    3941  (void) action;
    40   _Thread_State_release( executing, lock_context );
    41 
    42   api = executing->API_Extensions[ THREAD_API_RTEMS ];
    43   if ( !api )
    44     return;
    4542
    4643  /*
     
    4845   */
    4946
     47  api = executing->API_Extensions[ THREAD_API_RTEMS ];
    5048  asr = &api->Signal;
    5149  signal_set = _ASR_Get_posted_signals( asr );
     50
     51  _Thread_State_release( executing, lock_context );
    5252
    5353  if ( signal_set == 0 ) {
     
    7474  ISR_lock_Context    lock_context;
    7575
    76   _ISR_lock_ISR_disable( &lock_context );
    77   executing = _Thread_Executing;
     76  executing = _Thread_State_acquire_for_executing( &lock_context );
    7877  api = executing->API_Extensions[ THREAD_API_RTEMS ];
    7978  asr = &api->Signal;
    80 
    81   _ASR_Acquire_critical( asr, &lock_context );
    8279
    8380  if ( !_ASR_Is_null_handler( asr_handler ) ) {
     
    8885  }
    8986
    90   _ASR_Release( asr, &lock_context );
     87  _Thread_State_release( executing, &lock_context );
    9188  return RTEMS_SUCCESSFUL;
    9289}
  • cpukit/rtems/src/signalsend.c

    r6e4f929 r105b4e6  
    5252  asr = &api->Signal;
    5353
    54   _ASR_Acquire_critical( asr, &lock_context );
     54  _Thread_State_acquire_critical( the_thread, &lock_context );
    5555
    5656  if ( _ASR_Is_null_handler( asr->handler ) ) {
    57     _ASR_Release( asr, &lock_context );
     57    _Thread_State_release( the_thread, &lock_context );
    5858    return RTEMS_NOT_DEFINED;
    5959  }
     
    6363
    6464    _ASR_Post_signals( signal_set, &asr->signals_posted );
    65     _ASR_Release( asr, &lock_context );
    66     _Thread_State_acquire( the_thread, &lock_context );
    6765    _Thread_Add_post_switch_action(
    6866      the_thread,
     
    7573  } else {
    7674    _ASR_Post_signals( signal_set, &asr->signals_pending );
    77     _ASR_Release( asr, &lock_context );
     75    _Thread_State_release( the_thread, &lock_context );
    7876  }
    7977
  • cpukit/rtems/src/taskmode.c

    r6e4f929 r105b4e6  
    9999    bool is_asr_enabled = !_Modes_Is_asr_disabled( mode_set );
    100100
     101    _Thread_State_acquire( executing, &lock_context );
     102
    101103    if ( is_asr_enabled != asr->is_enabled ) {
    102104      asr->is_enabled = is_asr_enabled;
     
    104106      if ( _ASR_Swap_signals( asr ) != 0 ) {
    105107        needs_asr_dispatching = true;
    106         _Thread_State_acquire( executing, &lock_context );
    107108        _Thread_Add_post_switch_action(
    108109          executing,
     
    110111          _Signal_Action_handler
    111112        );
    112         _Thread_State_release( executing, &lock_context );
    113113      }
    114114    }
     115
     116    _Thread_State_release( executing, &lock_context );
    115117  }
    116118
  • cpukit/rtems/src/tasks.c

    r6e4f929 r105b4e6  
    2121#include <rtems/config.h>
    2222#include <rtems/sysinit.h>
    23 #include <rtems/rtems/asrimpl.h>
    2423#include <rtems/rtems/eventimpl.h>
    2524#include <rtems/rtems/tasksimpl.h>
     
    2827
    2928Thread_Information _RTEMS_tasks_Information;
    30 
    31 /*
    32  *  _RTEMS_tasks_Create_extension
    33  *
    34  *  This routine is an extension routine that is invoked as part
    35  *  of creating any type of task or thread in the system.  If the
    36  *  task is created via another API, then this routine is invoked
    37  *  and this API given the opportunity to initialize its extension
    38  *  area.
    39  */
    40 
    41 static bool _RTEMS_tasks_Create_extension(
    42   Thread_Control *executing,
    43   Thread_Control *created
    44 )
    45 {
    46   RTEMS_API_Control *api;
    47 
    48   api = created->API_Extensions[ THREAD_API_RTEMS ];
    49 
    50   _ASR_Create( &api->Signal );
    51 
    52   return true;
    53 }
    54 
    55 /*
    56  *  _RTEMS_tasks_Start_extension
    57  *
    58  *  This extension routine is invoked when a task is started for the
    59  *  first time.
    60  */
    6129
    6230static void _RTEMS_tasks_Start_extension(
     
    7341}
    7442
    75 static void _RTEMS_tasks_Delete_extension(
    76   Thread_Control *executing,
    77   Thread_Control *deleted
    78 )
    79 {
    80   RTEMS_API_Control *api;
    81 
    82   api = deleted->API_Extensions[ THREAD_API_RTEMS ];
    83 
    84   _ASR_Destroy( &api->Signal );
    85 }
    86 
    8743User_extensions_Control _RTEMS_tasks_User_extensions = {
    8844  .Callouts = {
    89     .thread_create  = _RTEMS_tasks_Create_extension,
    9045    .thread_start   = _RTEMS_tasks_Start_extension,
    91     .thread_restart = _RTEMS_tasks_Start_extension,
    92     .thread_delete  = _RTEMS_tasks_Delete_extension
     46    .thread_restart = _RTEMS_tasks_Start_extension
    9347  }
    9448};
  • cpukit/score/include/rtems/score/thread.h

    r6e4f929 r105b4e6  
    719719   * the following fields
    720720   *
     721   * - RTEMS_API_Control::Signal, and
    721722   * - Thread_Control::Post_switch_actions.
    722723   *
Note: See TracChangeset for help on using the changeset viewer.