コード例 #1
0
bool _Thread_Restart(
  Thread_Control            *the_thread,
  void                      *pointer_argument,
  Thread_Entry_numeric_type  numeric_argument
)
{
  if ( !_States_Is_dormant( the_thread->current_state ) ) {

    _Thread_Set_transient( the_thread );

    _Thread_Reset( the_thread, pointer_argument, numeric_argument );

    _Thread_Load_environment( the_thread );

    _Thread_Ready( the_thread );

    _User_extensions_Thread_restart( the_thread );

    if ( _Thread_Is_executing ( the_thread ) )
      _Thread_Restart_self();

    return true;
  }

  return false;
}
コード例 #2
0
ER rsm_tsk(
  ID tskid
)
{
  register Thread_Control *the_thread;
  Objects_Locations        location;

  the_thread = _ITRON_Task_Get( tskid, &location );
  switch ( location ) {
#if defined(RTEMS_MULTIPROCESSING)
    case OBJECTS_REMOTE:
#endif
    case OBJECTS_ERROR:
      return _ITRON_Task_Clarify_get_id_error( tskid );

    case OBJECTS_LOCAL:

      if ( _Thread_Is_executing( the_thread ) )
        _ITRON_return_errorno( E_OBJ );

      if ( _States_Is_dormant( the_thread->current_state ))
        _ITRON_return_errorno( E_OBJ );

      if ( ! _States_Is_suspended(the_thread->current_state) )
        _ITRON_return_errorno( E_OBJ );

      _Thread_Resume( the_thread, false );
      break;
  }

  _ITRON_return_errorno( E_OK );
}
コード例 #3
0
ファイル: threadstart.c プロジェクト: epicsdeb/rtems
bool _Thread_Start(
  Thread_Control            *the_thread,
  Thread_Start_types         the_prototype,
  void                      *entry_point,
  void                      *pointer_argument,
  Thread_Entry_numeric_type  numeric_argument
)
{
  if ( _States_Is_dormant( the_thread->current_state ) ) {

    the_thread->Start.entry_point      = (Thread_Entry) entry_point;

    the_thread->Start.prototype        = the_prototype;
    the_thread->Start.pointer_argument = pointer_argument;
    the_thread->Start.numeric_argument = numeric_argument;

    _Thread_Load_environment( the_thread );

    _Thread_Ready( the_thread );

    _User_extensions_Thread_start( the_thread );

    return true;
  }

  return false;
}
コード例 #4
0
ファイル: threadstart.c プロジェクト: gedare/rtems
bool _Thread_Start(
  Thread_Control                 *the_thread,
  const Thread_Entry_information *entry,
  ISR_lock_Context               *lock_context
)
{
  Per_CPU_Control *cpu_self;

  _Thread_State_acquire_critical( the_thread, lock_context );

  if ( !_States_Is_dormant( the_thread->current_state ) ) {
    _Thread_State_release( the_thread, lock_context );
    return false;
  }

  the_thread->Start.Entry = *entry;
  _Thread_Load_environment( the_thread );
  _Thread_Clear_state_locked( the_thread, STATES_ALL_SET );

  cpu_self = _Thread_Dispatch_disable_critical( lock_context );
  _Thread_State_release( the_thread, lock_context );

  _User_extensions_Thread_start( the_thread );

  _Thread_Dispatch_enable( cpu_self );
  return true;
}
コード例 #5
0
ファイル: threadrestart.c プロジェクト: Avanznow/rtems
void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
{
  _Assert( _Thread_Is_life_protected( executing->Life.state ) );

  if ( _States_Is_dormant( the_thread->current_state ) ) {
    _Thread_Make_zombie( the_thread );
  } else {
    if (
      the_thread != executing
        && !_Thread_Is_life_terminating( executing->Life.state )
    ) {
      /*
       * Wait for termination of victim thread.  If the executing thread is
       * also terminated, then do not wait.  This avoids potential cyclic
       * dependencies and thus dead lock.
       */
       the_thread->Life.terminator = executing;
       _Thread_Set_state( executing, STATES_WAITING_FOR_TERMINATION );
    }

    _Thread_Request_life_change(
      the_thread,
      executing,
      executing->current_priority,
      THREAD_LIFE_TERMINATING
    );
  }
}
コード例 #6
0
void _Thread_Cancel(
  Thread_Control *the_thread,
  Thread_Control *executing,
  void           *exit_value
)
{
  ISR_lock_Context   lock_context;
  Thread_Life_state  previous;
  Per_CPU_Control   *cpu_self;
  Priority_Control   priority;

  _Assert( the_thread != executing );

  _Thread_State_acquire( the_thread, &lock_context );

  _Thread_Set_exit_value( the_thread, exit_value );
  previous = _Thread_Change_life_locked(
    the_thread,
    0,
    THREAD_LIFE_TERMINATING,
    0
  );

  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
  priority = _Thread_Get_priority( executing );

  if ( _States_Is_dormant( the_thread->current_state ) ) {
    _Thread_State_release( the_thread, &lock_context );
    _Thread_Make_zombie( the_thread );
  } else if ( _Thread_Is_life_change_allowed( previous ) ) {
    _Thread_Add_life_change_request( the_thread );
    _Thread_State_release( the_thread, &lock_context );

    _Thread_Finalize_life_change( the_thread, priority );
  } else {
    _Thread_Add_life_change_request( the_thread );
    _Thread_Clear_state_locked( the_thread, STATES_SUSPENDED );
    _Thread_State_release( the_thread, &lock_context );

    _Thread_Raise_real_priority( the_thread, priority );
    _Thread_Remove_life_change_request( the_thread );
  }

  _Thread_Dispatch_enable( cpu_self );
}
コード例 #7
0
bool _Thread_Restart_other(
  Thread_Control                 *the_thread,
  const Thread_Entry_information *entry,
  ISR_lock_Context               *lock_context
)
{
  Thread_Life_state  previous;
  Per_CPU_Control   *cpu_self;

  _Thread_State_acquire_critical( the_thread, lock_context );

  if ( _States_Is_dormant( the_thread->current_state ) ) {
    _Thread_State_release( the_thread, lock_context );
    return false;
  }

  the_thread->Start.Entry = *entry;
  previous = _Thread_Change_life_locked(
    the_thread,
    0,
    THREAD_LIFE_RESTARTING,
    0
  );

  cpu_self = _Thread_Dispatch_disable_critical( lock_context );

  if ( _Thread_Is_life_change_allowed( previous ) ) {
    _Thread_Add_life_change_request( the_thread );
    _Thread_State_release( the_thread, lock_context );

    _Thread_Finalize_life_change(
      the_thread,
      the_thread->Start.initial_priority
    );
  } else {
    _Thread_Clear_state_locked( the_thread, STATES_SUSPENDED );
    _Thread_State_release( the_thread, lock_context );
  }

  _Thread_Dispatch_enable( cpu_self );
  return true;
}
コード例 #8
0
ER chg_pri(
  ID  tskid,
  PRI tskpri
)
{
  register Thread_Control *the_thread;
  Objects_Locations        location;
  Priority_Control         new_priority;

  the_thread = _ITRON_Task_Get( tskid, &location );
  switch ( location ) {
#if defined(RTEMS_MULTIPROCESSING)
    case OBJECTS_REMOTE:
#endif
    case OBJECTS_ERROR:
      return _ITRON_Task_Clarify_get_id_error( tskid );

    case OBJECTS_LOCAL:
      if (_States_Is_dormant( the_thread->current_state ))
        _ITRON_return_errorno( E_OBJ );

      if (( tskpri <= 0 ) || ( tskpri >= PRIORITY_MAXIMUM-1 ))
        _ITRON_return_errorno( E_PAR );

      new_priority = _ITRON_Task_Priority_to_Core( tskpri );
      the_thread->real_priority = new_priority;

      /*
       * The priority should not be changed until later if priority
       * inheratance has occured.
       */

      if ( the_thread->resource_count == 0 ||
           the_thread->current_priority > new_priority )
        _Thread_Change_priority( the_thread, new_priority, false );

      break;
  }

  _ITRON_return_errorno( E_OK );
}
コード例 #9
0
ファイル: threadrestart.c プロジェクト: Avanznow/rtems
bool _Thread_Restart(
  Thread_Control                 *the_thread,
  Thread_Control                 *executing,
  const Thread_Entry_information *entry
)
{
  if ( !_States_Is_dormant( the_thread->current_state ) ) {
    the_thread->Start.Entry = *entry;

    _Thread_Request_life_change(
      the_thread,
      executing,
      the_thread->Start.initial_priority,
      THREAD_LIFE_RESTARTING
    );

    return true;
  }

  return false;
}
コード例 #10
0
ファイル: threadrestart.c プロジェクト: ray-x/rtems
bool _Thread_Restart(
  Thread_Control            *the_thread,
  Thread_Control            *executing,
  void                      *pointer_argument,
  Thread_Entry_numeric_type  numeric_argument
)
{
  if ( !_States_Is_dormant( the_thread->current_state ) ) {
    the_thread->Start.pointer_argument = pointer_argument;
    the_thread->Start.numeric_argument = numeric_argument;

    _Thread_Request_life_change(
      the_thread,
      executing,
      the_thread->Start.initial_priority,
      THREAD_LIFE_RESTARTING
    );

    return true;
  }

  return false;
}
コード例 #11
0
ファイル: ref_tsk.c プロジェクト: epicsdeb/rtems
ER ref_tsk(
    T_RTSK *pk_rtsk,
    ID      tskid
)
{
    register Thread_Control *the_thread;
    Objects_Locations        location;
    Priority_Control         core_priority;

    if (!pk_rtsk)
        return E_PAR;

    the_thread = _ITRON_Task_Get( tskid, &location );
    switch ( location ) {
#if defined(RTEMS_MULTIPROCESSING)
    case OBJECTS_REMOTE:
#endif
    case OBJECTS_ERROR:
        return _ITRON_Task_Clarify_get_id_error( tskid );

    case OBJECTS_LOCAL:

        if ( location != OBJECTS_LOCAL )
            return  _ITRON_Task_Clarify_get_id_error( tskid );

        /*
         * The following are extended functions [level X ].
         * XXX - tskwait, wid, wupcnt, and tskatr are presently not implemented.
         */

        pk_rtsk->tskwait = 0;
        pk_rtsk->wid     = 0;
        pk_rtsk->wupcnt  = 0;
        pk_rtsk->suscnt  = the_thread->suspend_count;
        pk_rtsk->tskatr  = 0;       /* XXX - Not correctly implemented */
        pk_rtsk->task    = (FP) the_thread->Start.entry_point;
        core_priority    = the_thread->Start.initial_priority;
        pk_rtsk->itskpri = _ITRON_Task_Core_to_Priority( core_priority );
        pk_rtsk->stksz   = the_thread->Start.Initial_stack.size;

        /*
         * The following are required.
         */

        pk_rtsk->exinf   = NULL;   /* extended information */
        pk_rtsk->tskpri  =
            _ITRON_Task_Core_to_Priority(the_thread->current_priority);

        /*
         * Mask in the tskstat information
         * Convert the task state XXX double check this
         */

        pk_rtsk->tskstat = 0;
        if ( the_thread == _Thread_Executing )
            pk_rtsk->tskstat |= TTS_RUN;
        if ( _States_Is_ready(the_thread->current_state) )
            pk_rtsk->tskstat |= TTS_RDY;
        if ( _States_Is_dormant( the_thread->current_state) )
            pk_rtsk->tskstat |= TTS_DMT;
        if ( _States_Is_suspended(the_thread->current_state) )
            pk_rtsk->tskstat |= TTS_SUS;
        if ( _States_Is_blocked(the_thread->current_state) )
            pk_rtsk->tskstat |= TTS_WAI;

        break;
    }

    _ITRON_return_errorno( E_OK );

}