Changeset 424ffe4d in rtems


Ignore:
Timestamp:
Aug 11, 2016, 8:26:57 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
55faa44
Parents:
a827447
git-author:
Sebastian Huber <sebastian.huber@…> (08/11/16 08:26:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/11/16 09:13:42)
Message:

score: Introduce thread queue surrender operation

This is an optimization for _Thread_queue_Surrender(). It helps to
encapsulate the priority boosting in the priority inheritance thread
queue operations.

Location:
cpukit/score
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/threadq.h

    ra827447 r424ffe4d  
    372372
    373373/**
     374 * @brief Thread queue surrender operation.
     375 *
     376 * This operation must dequeue and return the first thread on the queue.
     377 *
     378 * @param[in] queue The actual thread queue.
     379 * @param[in] heads The thread queue heads.  It must not be NULL.
     380 * @param[in] previous_owner The previous owner of the thread queue.
     381 *
     382 * @return The previous first thread on the queue.
     383 */
     384typedef Thread_Control *( *Thread_queue_Surrender_operation )(
     385  Thread_queue_Queue *queue,
     386  Thread_queue_Heads *heads,
     387  Thread_Control     *previous_owner
     388);
     389
     390/**
    374391 * @brief Thread queue first operation.
    375392 *
     
    417434
    418435  /**
     436   * @brief Thread queue surrender operation.
     437   */
     438  Thread_queue_Surrender_operation surrender;
     439
     440  /**
    419441   * @brief Thread queue first operation.
    420442   */
  • cpukit/score/include/rtems/score/threadqimpl.h

    ra827447 r424ffe4d  
    947947}
    948948
    949 /**
    950  * @brief Boosts the priority of the thread if threads of another scheduler
    951  * instance are enqueued on the thread queue.
    952  *
    953  * The thread queue must use the priority waiting discipline.
    954  *
    955  * @param[in] queue The actual thread queue.
    956  * @param[in] the_thread The thread to boost the priority if necessary.
    957  */
    958 #if defined(RTEMS_SMP)
    959 void _Thread_queue_Boost_priority(
    960   Thread_queue_Queue *queue,
    961   Thread_Control     *the_thread
    962 );
    963 #else
    964 RTEMS_INLINE_ROUTINE void _Thread_queue_Boost_priority(
    965   Thread_queue_Queue *queue,
    966   Thread_Control     *the_thread
    967 )
    968 {
    969   (void) queue;
    970   (void) the_thread;
    971 }
    972 #endif
    973 
    974949#if defined(RTEMS_MULTIPROCESSING)
    975950void _Thread_queue_MP_callout_do_nothing(
  • cpukit/score/src/threadqenqueue.c

    ra827447 r424ffe4d  
    597597    bool            unblock;
    598598
    599     new_owner = ( *operations->first )( heads );
     599    new_owner = ( *operations->surrender )( queue, heads, previous_owner );
    600600    queue->owner = new_owner;
    601601
     
    605605    {
    606606      ++new_owner->resource_count;
    607       _Thread_queue_Boost_priority( queue, new_owner );
    608     }
    609 
    610     ( *operations->extract )( queue, new_owner );
     607    }
     608
    611609    unblock = _Thread_queue_Make_ready_again( new_owner );
    612610
  • cpukit/score/src/threadqops.c

    ra827447 r424ffe4d  
    7272static void _Thread_queue_Queue_extract(
    7373  Thread_queue_Queue *queue,
     74  Thread_queue_Heads *heads,
    7475  Thread_Control     *the_thread,
    7576  void             ( *extract )( Thread_queue_Heads *, Thread_Control * )
    7677)
    7778{
    78   Thread_queue_Heads *heads = queue->heads;
    79 
    8079  _Assert( heads != NULL );
    8180
     
    143142  _Thread_queue_Queue_extract(
    144143    queue,
     144    queue->heads,
    145145    the_thread,
    146146    _Thread_queue_FIFO_do_extract
     
    159159
    160160  return THREAD_CHAIN_NODE_TO_THREAD( first );
     161}
     162
     163static Thread_Control *_Thread_queue_FIFO_surrender(
     164  Thread_queue_Queue *queue,
     165  Thread_queue_Heads *heads,
     166  Thread_Control     *previous_owner
     167)
     168{
     169  Thread_Control *first;
     170
     171  first = _Thread_queue_FIFO_first( heads );
     172  _Thread_queue_Queue_extract(
     173    queue,
     174    heads,
     175    first,
     176    _Thread_queue_FIFO_do_extract
     177  );
     178
     179  return first;
    161180}
    162181
     
    297316  _Thread_queue_Queue_extract(
    298317    queue,
     318    queue->heads,
    299319    the_thread,
    300320    _Thread_queue_Priority_do_extract
     
    321341
    322342  return THREAD_RBTREE_NODE_TO_THREAD( first );
     343}
     344
     345static Thread_Control *_Thread_queue_Priority_surrender(
     346  Thread_queue_Queue *queue,
     347  Thread_queue_Heads *heads,
     348  Thread_Control     *previous_owner
     349)
     350{
     351  Thread_Control *first;
     352
     353  first = _Thread_queue_Priority_first( heads );
     354  _Thread_queue_Queue_extract(
     355    queue,
     356    heads,
     357    first,
     358    _Thread_queue_Priority_do_extract
     359  );
     360
     361  return first;
    323362}
    324363
     
    375414}
    376415
    377 #if defined(RTEMS_SMP)
    378 void _Thread_queue_Boost_priority(
    379   Thread_queue_Queue *queue,
    380   Thread_Control     *the_thread
    381 )
    382 {
    383   Thread_queue_Heads *heads = queue->heads;
    384 
     416static void _Thread_queue_Boost_priority(
     417  Thread_queue_Heads *heads,
     418  Thread_Control     *the_thread
     419)
     420{
     421#if defined(RTEMS_SMP)
    385422  if ( !_Chain_Has_only_one_node( &heads->Heads.Fifo ) ) {
    386423    const Scheduler_Control *scheduler;
     
    395432    _Scheduler_Thread_set_priority( the_thread, boost_priority, false );
    396433  }
    397 }
    398 #endif
     434#else
     435  (void) heads;
     436  (void) the_thread;
     437#endif
     438}
     439
     440static Thread_Control *_Thread_queue_Priority_inherit_surrender(
     441  Thread_queue_Queue *queue,
     442  Thread_queue_Heads *heads,
     443  Thread_Control     *previous_owner
     444)
     445{
     446  Thread_Control *first;
     447
     448  first = _Thread_queue_Priority_first( heads );
     449  _Thread_queue_Boost_priority( heads, first );
     450  _Thread_queue_Queue_extract(
     451    queue,
     452    heads,
     453    first,
     454    _Thread_queue_Priority_do_extract
     455  );
     456
     457  return first;
     458}
    399459
    400460const Thread_queue_Operations _Thread_queue_Operations_default = {
     
    412472  .enqueue = _Thread_queue_FIFO_enqueue,
    413473  .extract = _Thread_queue_FIFO_extract,
     474  .surrender = _Thread_queue_FIFO_surrender,
    414475  .first = _Thread_queue_FIFO_first
    415476};
     
    419480  .enqueue = _Thread_queue_Priority_enqueue,
    420481  .extract = _Thread_queue_Priority_extract,
     482  .surrender = _Thread_queue_Priority_surrender,
    421483  .first = _Thread_queue_Priority_first
    422484};
     
    426488  .enqueue = _Thread_queue_Priority_inherit_enqueue,
    427489  .extract = _Thread_queue_Priority_extract,
     490  .surrender = _Thread_queue_Priority_inherit_surrender,
    428491  .first = _Thread_queue_Priority_first
    429492};
Note: See TracChangeset for help on using the changeset viewer.