Changeset d78d529 in rtems


Ignore:
Timestamp:
Nov 14, 2016, 8:11:07 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
82d30a3
Parents:
acc6d9bf
git-author:
Sebastian Huber <sebastian.huber@…> (11/14/16 08:11:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/18/16 06:30:31)
Message:

score: Add and use _Thread_Dispatch_direct()

This function is useful for operations which synchronously block, e.g.
self restart, self deletion, yield, sleep. It helps to detect if these
operations are called in the wrong context. Since the thread dispatch
necessary indicator is not used, this is more robust in some SMP
situations.

Update #2751.

Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/nanosleep.c

    racc6d9bf rd78d529  
    9797  cpu_self = _Thread_Dispatch_disable();
    9898  _Thread_Yield( executing );
    99   _Thread_Dispatch_enable( cpu_self );
     99  _Thread_Dispatch_direct( cpu_self );
    100100  if ( rmtp ) {
    101101    rmtp->tv_sec = 0;
  • cpukit/posix/src/sched_yield.c

    racc6d9bf rd78d529  
    3131  cpu_self = _Thread_Dispatch_disable();
    3232    _Thread_Yield( _Per_CPU_Get_executing( cpu_self ) );
    33   _Thread_Dispatch_enable( cpu_self );
     33  _Thread_Dispatch_direct( cpu_self );
    3434  return 0;
    3535}
  • cpukit/rtems/src/taskwakeafter.c

    racc6d9bf rd78d529  
    4949      );
    5050    }
    51   _Thread_Dispatch_enable( cpu_self );
     51  _Thread_Dispatch_direct( cpu_self );
    5252  return RTEMS_SUCCESSFUL;
    5353}
  • cpukit/sapi/src/interrtext.c

    racc6d9bf rd78d529  
    5757  "INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL",
    5858  "INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK",
    59   "INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE"
     59  "INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE",
     60  "INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL"
    6061};
    6162
  • cpukit/score/include/rtems/score/interr.h

    racc6d9bf rd78d529  
    166166  INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL,
    167167  INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK,
    168   INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
     168  INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE,
     169  INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL
    169170} Internal_errors_Core_list;
    170171
  • cpukit/score/include/rtems/score/threaddispatch.h

    racc6d9bf rd78d529  
    9494 */
    9595void _Thread_Dispatch( void );
     96
     97/**
     98 * @brief Directly do a thread dispatch.
     99 *
     100 * Must be called with a thread dispatch disable level of one, otherwise the
     101 * INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will occur.  This function
     102 * is useful for operations which synchronously block, e.g. self restart, self
     103 * deletion, yield, sleep.
     104 *
     105 * @param[in] cpu_self The current processor.
     106 *
     107 * @see _Thread_Dispatch().
     108 */
     109void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self );
    96110
    97111/**
  • cpukit/score/src/threaddispatch.c

    racc6d9bf rd78d529  
    234234  }
    235235}
     236
     237void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self )
     238{
     239  ISR_Level level;
     240
     241  if ( cpu_self->thread_dispatch_disable_level != 1 ) {
     242    _Terminate(
     243      INTERNAL_ERROR_CORE,
     244      0,
     245      INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL
     246    );
     247  }
     248
     249  _ISR_Local_disable( level );
     250  _Thread_Do_dispatch( cpu_self, level );
     251}
  • cpukit/score/src/threadrestart.c

    racc6d9bf rd78d529  
    345345  if ( _Thread_Is_life_terminating( previous_life_state ) ) {
    346346    cpu_self = _Thread_Wait_for_join( executing, cpu_self );
    347 
    348347    _Thread_Make_zombie( executing );
    349 
    350     /* FIXME: Workaround for https://devel.rtems.org/ticket/2751 */
    351     cpu_self->dispatch_necessary = true;
    352 
    353     _Assert( cpu_self->heir != executing );
    354     _Thread_Dispatch_enable( cpu_self );
     348    _Thread_Dispatch_direct( cpu_self );
    355349    RTEMS_UNREACHABLE();
    356350  }
  • testsuites/sptests/Makefile.am

    racc6d9bf rd78d529  
    3434    spsem_err02 sptask_err01 spevent_err03 sptask_err03 sptask_err02 \
    3535    sptask_err04 spclock_err01
     36_SUBDIRS += spfatal29
    3637_SUBDIRS += spmutex01
    3738_SUBDIRS += spextensions01
  • testsuites/sptests/configure.ac

    racc6d9bf rd78d529  
    194194spfatal25/Makefile
    195195spfatal27/Makefile
     196spfatal29/Makefile
    196197spfifo01/Makefile
    197198spfifo02/Makefile
  • testsuites/sptests/spinternalerror02/init.c

    racc6d9bf rd78d529  
    3737
    3838  rtems_test_assert(
    39     error - 3 == INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
     39    error - 3 == INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL
    4040  );
    4141}
Note: See TracChangeset for help on using the changeset viewer.