Esempio n. 1
0
void _Scheduler_simple_Update_priority(
  const Scheduler_Control *scheduler,
  Thread_Control          *the_thread,
  Scheduler_Node          *node
)
{
  Scheduler_simple_Context *context;
  bool                      prepend_it;

  if ( !_Thread_Is_ready( the_thread ) ) {
    /* Nothing to do */
    return;
  }

  context = _Scheduler_simple_Get_context( scheduler );
  _Scheduler_Node_get_priority( node, &prepend_it );

  _Scheduler_simple_Extract( scheduler, the_thread, node );

  if ( prepend_it ) {
    _Scheduler_simple_Insert_priority_lifo( &context->Ready, the_thread );
  } else {
    _Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread );
  }

  _Scheduler_simple_Schedule_body( scheduler, the_thread, false );
}
Esempio n. 2
0
void _Scheduler_simple_Yield(
  const Scheduler_Control *scheduler,
  Thread_Control          *the_thread
)
{
  Scheduler_simple_Context *context =
    _Scheduler_simple_Get_context( scheduler );
  ISR_Level       level;

  _ISR_Disable( level );

    _Chain_Extract_unprotected( &the_thread->Object.Node );
    _Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread );

    _ISR_Flash( level );

    _Scheduler_simple_Schedule_body( scheduler, the_thread, false );

  _ISR_Enable( level );
}
Esempio n. 3
0
Scheduler_Void_or_bool _Scheduler_simple_Unblock(
  const Scheduler_Control *scheduler,
  Thread_Control          *the_thread,
  Scheduler_Node          *node
)
{
  Scheduler_simple_Context *context;
  Priority_Control          priority;

  (void) node;

  context = _Scheduler_simple_Get_context( scheduler );
  _Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread );
  priority = _Thread_Get_priority( the_thread );

  /*
   *  If the thread that was unblocked is more important than the heir,
   *  then we have a new heir.  This may or may not result in a
   *  context switch.
   *
   *  Normal case:
   *    If the current thread is preemptible, then we need to do
   *    a context switch.
   *  Pseudo-ISR case:
   *    Even if the thread isn't preemptible, if the new heir is
   *    a pseudo-ISR system task, we need to do a context switch.
   */
  if ( priority < _Thread_Get_priority( _Thread_Heir ) ) {
    _Scheduler_Update_heir(
      the_thread,
      priority == PRIORITY_PSEUDO_ISR
    );
  }

  SCHEDULER_RETURN_VOID_OR_BOOL;
}