Esempio n. 1
0
static void _Thread_queue_Priority_do_enqueue(
  Thread_queue_Heads *heads,
  Thread_Control     *the_thread
)
{
  Thread_queue_Priority_queue *priority_queue;
  Scheduler_Node              *scheduler_node;
  Priority_Control             current_priority;

  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );

#if defined(RTEMS_SMP)
  if ( _RBTree_Is_empty( &priority_queue->Queue ) ) {
    _Chain_Append_unprotected( &heads->Heads.Fifo, &priority_queue->Node );
  }
#endif

  scheduler_node = _Scheduler_Thread_get_own_node( the_thread );
  current_priority = _Thread_Get_priority( the_thread );

  _RBTree_Initialize_node( &scheduler_node->Wait.Node.RBTree );
  _RBTree_Insert_inline(
    &priority_queue->Queue,
    &scheduler_node->Wait.Node.RBTree,
    &current_priority,
    _Thread_queue_Priority_less
  );
}
Esempio n. 2
0
static void _Thread_queue_Priority_priority_change(
  Thread_queue_Queue *queue,
  Thread_Control     *the_thread,
  Priority_Control    new_priority
)
{
  Thread_queue_Heads          *heads;
  Thread_queue_Priority_queue *priority_queue;
  Scheduler_Node              *scheduler_node;

  heads = queue->heads;
  _Assert( heads != NULL );

  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );
  scheduler_node = _Scheduler_Thread_get_own_node( the_thread );

  _RBTree_Extract(
    &priority_queue->Queue,
    &scheduler_node->Wait.Node.RBTree
  );
  _RBTree_Insert_inline(
    &priority_queue->Queue,
    &scheduler_node->Wait.Node.RBTree,
    &new_priority,
    _Thread_queue_Priority_less
  );
}
Esempio n. 3
0
static bool _Thread_queue_Link_add(
    Thread_queue_Link  *link,
    Thread_queue_Queue *source,
    Thread_queue_Queue *target
)
{
    Thread_queue_Links *links;
    Thread_queue_Queue *recursive_target;
    ISR_lock_Context    lock_context;

    link->source = source;
    link->target = target;

    links = &_Thread_queue_Links;
    recursive_target = target;

    _ISR_lock_Acquire( &links->Lock, &lock_context );

    while ( true ) {
        Thread_queue_Link *recursive_link;

        recursive_link = _Thread_queue_Link_find( links, recursive_target );

        if ( recursive_link == NULL ) {
            break;
        }

        recursive_target = recursive_link->target;

        if ( recursive_target == source ) {
            _ISR_lock_Release( &links->Lock, &lock_context );
            return false;
        }
    }

    _RBTree_Insert_inline(
        &links->Links,
        &link->Registry_node,
        source,
        _Thread_queue_Link_less
    );

    _ISR_lock_Release( &links->Lock, &lock_context );
    return true;
}
static void _Thread_queue_Priority_do_enqueue(
  Thread_queue_Heads *heads,
  Thread_Control     *the_thread
)
{
  Thread_queue_Priority_queue *priority_queue =
    _Thread_queue_Priority_queue( heads, the_thread );
  Priority_Control current_priority;

#if defined(RTEMS_SMP)
  if ( _RBTree_Is_empty( &priority_queue->Queue ) ) {
    _Chain_Append_unprotected( &heads->Heads.Fifo, &priority_queue->Node );
  }
#endif

  current_priority = the_thread->current_priority;
  _RBTree_Insert_inline(
    &priority_queue->Queue,
    &the_thread->Wait.Node.RBTree,
    &current_priority,
    _Thread_queue_Priority_less
  );
}
static void _Thread_queue_Priority_priority_change(
  Thread_Control     *the_thread,
  Priority_Control    new_priority,
  Thread_queue_Queue *queue
)
{
  Thread_queue_Heads          *heads = queue->heads;
  Thread_queue_Priority_queue *priority_queue;

  _Assert( heads != NULL );

  priority_queue = _Thread_queue_Priority_queue( heads, the_thread );

  _RBTree_Extract(
    &priority_queue->Queue,
    &the_thread->Wait.Node.RBTree
  );
  _RBTree_Insert_inline(
    &priority_queue->Queue,
    &the_thread->Wait.Node.RBTree,
    &new_priority,
    _Thread_queue_Priority_less
  );
}
Esempio n. 6
0
Thread_Control *_Thread_MP_Allocate_proxy (
  States_Control  the_state
)
{
  Thread_Proxy_control *the_proxy;
  ISR_lock_Context      lock_context;

  _Thread_MP_Proxies_acquire( &lock_context );

  the_proxy = (Thread_Proxy_control *)
    _Chain_Get_unprotected( &_Thread_MP_Inactive_proxies );
  if ( the_proxy != NULL ) {
    Thread_Control   *executing;
    MP_packet_Prefix *receive_packet;
    Objects_Id        source_tid;

    executing = _Thread_Executing;
    receive_packet = _MPCI_Receive_server_tcb->receive_packet;
    source_tid = receive_packet->source_tid;

    executing->Wait.return_code = THREAD_STATUS_PROXY_BLOCKING;

    the_proxy->receive_packet = receive_packet;
    the_proxy->Object.id = source_tid;
    the_proxy->current_priority = receive_packet->source_priority;
    the_proxy->current_state = _States_Set( STATES_DORMANT, the_state );

    the_proxy->Wait.count                   = executing->Wait.count;
    the_proxy->Wait.return_argument         = executing->Wait.return_argument;
    the_proxy->Wait.return_argument_second  = executing->Wait.return_argument_second;
    the_proxy->Wait.option                  = executing->Wait.option;
    the_proxy->Wait.return_code             = executing->Wait.return_code;
    the_proxy->Wait.timeout_code            = executing->Wait.timeout_code;

    the_proxy->thread_queue_callout = _Thread_queue_MP_callout_do_nothing;

    _RBTree_Insert_inline(
      &_Thread_MP_Active_proxies,
      &the_proxy->Active,
      &source_tid,
      _Thread_MP_Proxy_less
    );

    _Thread_MP_Proxies_release( &lock_context );

    return (Thread_Control *) the_proxy;
  }

  _Thread_MP_Proxies_release( &lock_context );

  _Terminate(
    INTERNAL_ERROR_CORE,
    true,
    INTERNAL_ERROR_OUT_OF_PROXIES
  );

  /*
   *  NOTE: The following return ensures that the compiler will
   *        think that all paths return a value.
   */

  return NULL;
}