Changeset d2711c37 in rtems


Ignore:
Timestamp:
Dec 5, 2017, 3:54:56 PM (2 years ago)
Author:
Joel Sherrill <joel@…>
Branches:
master
Children:
e9e0f1d4
Parents:
9526b034
git-author:
Joel Sherrill <joel@…> (12/05/17 15:54:56)
git-committer:
Joel Sherrill <joel@…> (12/06/17 18:48:45)
Message:

taskmode.c: Ensure all error checking is done before modifying executing

Also use single conditional expressions to simplify error checking.
Combined, this all resulted in a block of SMP enabled error checking.

Updates #3000.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/taskmode.c

    r9526b034 rd2711c37  
    4444    return RTEMS_INVALID_ADDRESS;
    4545
     46#if defined( RTEMS_SMP )
     47  /*
     48   * When in SMP, you cannot disable preemption for a thread or
     49   * alter its interrupt level. It must be fully preemptible with
     50   * all interrupts enabled.
     51   */
     52  if ( rtems_configuration_is_smp_enabled() ) {
     53    if ( mask & RTEMS_PREEMPT_MASK ) {
     54      if ( !_Modes_Is_preempt( mode_set ) ) {
     55        return RTEMS_NOT_IMPLEMENTED;
     56      }
     57    }
     58
     59    if ( mask & RTEMS_INTERRUPT_MASK ) {
     60      return RTEMS_NOT_IMPLEMENTED;
     61    }
     62  }
     63#endif
     64
     65  /*
     66   * Complete all error checking before doing any operations which
     67   * impact the executing thread. There should be no errors returned
     68   * past this point.
     69   */
     70 
    4671  executing     = _Thread_Get_executing();
    4772  api = executing->API_Extensions[ THREAD_API_RTEMS ];
     
    6489   */
    6590  preempt_enabled = false;
     91#if !defined( RTEMS_SMP )
    6692  if ( mask & RTEMS_PREEMPT_MASK ) {
    67 #if defined( RTEMS_SMP )
    6893    if ( rtems_configuration_is_smp_enabled() &&
    6994         !_Modes_Is_preempt( mode_set ) ) {
    7095      return RTEMS_NOT_IMPLEMENTED;
    7196    }
    72 #endif
    7397    bool is_preempt_enabled = _Modes_Is_preempt( mode_set );
    7498
     
    76100    executing->is_preemptible = is_preempt_enabled;
    77101  }
     102#endif
    78103
    79104  if ( mask & RTEMS_TIMESLICE_MASK ) {
     
    89114   *  Set the new interrupt level
    90115   */
    91   if ( mask & RTEMS_INTERRUPT_MASK )
     116#if !defined( RTEMS_SMP )
     117  if ( mask & RTEMS_INTERRUPT_MASK ) {
    92118    _Modes_Set_interrupt_level( mode_set );
     119  }
     120#endif
    93121
    94122  /*
Note: See TracChangeset for help on using the changeset viewer.