Changeset 424ffe4d in rtems for cpukit/score/src/threadqops.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.