Changeset 97f7dac in rtems


Ignore:
Timestamp:
Oct 21, 2016, 7:23:48 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
9c238e1
Parents:
73a193f
git-author:
Sebastian Huber <sebastian.huber@…> (10/21/16 07:23:48)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/02/16 09:05:44)
Message:

score: Delete _Scheduler_Ask_for_help_if_necessary

Delete Thread_Control::Resource_node.

Update #2556.

Location:
cpukit/score
Files:
4 edited

Legend:

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

    r73a193f r97f7dac  
    197197}
    198198
    199 #if defined(RTEMS_SMP)
    200 typedef struct {
    201   Thread_Control *needs_help;
    202   Thread_Control *next_needs_help;
    203 } Scheduler_Ask_for_help_context ;
    204 
    205 RTEMS_INLINE_ROUTINE bool _Scheduler_Ask_for_help_visitor(
    206   Resource_Node *resource_node,
    207   void          *arg
    208 )
    209 {
    210   bool done;
    211   Scheduler_Ask_for_help_context *help_context = arg;
    212   Thread_Control *previous_needs_help = help_context->needs_help;
    213   Thread_Control *next_needs_help;
    214   Thread_Control *offers_help =
    215     THREAD_RESOURCE_NODE_TO_THREAD( resource_node );
    216   const Scheduler_Control *scheduler = _Scheduler_Get_own( offers_help );
    217 
    218   next_needs_help = ( *scheduler->Operations.ask_for_help_X )(
    219     scheduler,
    220     offers_help,
    221     previous_needs_help
    222   );
    223 
    224   done = next_needs_help != previous_needs_help;
    225 
    226   if ( done ) {
    227     help_context->next_needs_help = next_needs_help;
    228   }
    229 
    230   return done;
    231 }
    232 
    233 /**
    234  * @brief Ask threads depending on resources owned by the thread for help.
    235  *
    236  * A thread is in need for help if it lost its assigned processor due to
    237  * pre-emption by a higher priority thread or it was not possible to assign it
    238  * a processor since its priority is to low on its current scheduler instance.
    239  *
    240  * The run-time of this function depends on the size of the resource tree of
    241  * the thread needing help and other resource trees in case threads in need for
    242  * help are produced during this operation.
    243  *
    244  * @param[in] needs_help The thread needing help.
    245  */
    246 RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help_X(
    247   Thread_Control *needs_help
    248 )
    249 {
    250   do {
    251     const Scheduler_Control *scheduler = _Scheduler_Get_own( needs_help );
    252 
    253     needs_help = ( *scheduler->Operations.ask_for_help_X )(
    254       scheduler,
    255       needs_help,
    256       needs_help
    257     );
    258 
    259     if ( needs_help != NULL ) {
    260       Scheduler_Ask_for_help_context help_context = { needs_help, NULL };
    261 
    262       _Resource_Iterate(
    263         &needs_help->Resource_node,
    264         _Scheduler_Ask_for_help_visitor,
    265         &help_context
    266       );
    267 
    268       needs_help = help_context.next_needs_help;
    269     }
    270   } while ( needs_help != NULL );
    271 }
    272 
    273 RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help_if_necessary(
    274   Thread_Control *needs_help
    275 )
    276 {
    277   if (
    278     needs_help != NULL
    279       && _Resource_Node_owns_resources( &needs_help->Resource_node )
    280   ) {
    281     Scheduler_Node *node = _Thread_Scheduler_get_own_node( needs_help );
    282 
    283     if (
    284       node->help_state != SCHEDULER_HELP_ACTIVE_RIVAL
    285         || _Scheduler_Node_get_user( node ) != needs_help
    286     ) {
    287       _Scheduler_Ask_for_help_X( needs_help );
    288     }
    289   }
    290 }
    291 #endif
    292 
    293199/**
    294200 * @brief Scheduler yield with a particular thread.
     
    321227    _Thread_Scheduler_get_home_node( the_thread )
    322228  );
    323   _Scheduler_Ask_for_help_if_necessary( needs_help );
    324229  _Scheduler_Release_critical( scheduler, &lock_context );
    325230
     
    456361    scheduler_node
    457362  );
    458   _Scheduler_Ask_for_help_if_necessary( needs_help );
    459363  _Scheduler_Release_critical( scheduler, &lock_context );
    460364
     
    526430    const Scheduler_Control *scheduler;
    527431    ISR_lock_Context         lock_context;
    528     Thread_Control          *needs_help;
    529432
    530433    scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node );
     
    532435
    533436    _Scheduler_Acquire_critical( scheduler, &lock_context );
    534     needs_help = ( *scheduler->Operations.update_priority )(
     437    ( *scheduler->Operations.update_priority )(
    535438      scheduler,
    536439      the_thread,
    537440      scheduler_node
    538441    );
    539     _Scheduler_Ask_for_help_if_necessary( needs_help );
    540442    _Scheduler_Release_critical( scheduler, &lock_context );
    541443
  • cpukit/score/include/rtems/score/thread.h

    r73a193f r97f7dac  
    3030#include <rtems/score/object.h>
    3131#include <rtems/score/priority.h>
    32 #include <rtems/score/resource.h>
    3332#include <rtems/score/schedulernode.h>
    3433#include <rtems/score/stack.h>
     
    770769#endif
    771770
    772 #if defined(RTEMS_SMP)
    773   /**
    774    * @brief Resource node to build a dependency tree in case this thread owns
    775    * resources or depends on a resource.
    776    */
    777   Resource_Node            Resource_node;
    778 #endif
    779771#if defined(RTEMS_MULTIPROCESSING)
    780772  /** This field is true if the thread is offered globally */
  • cpukit/score/include/rtems/score/threadimpl.h

    r73a193f r97f7dac  
    2828#include <rtems/score/isr.h>
    2929#include <rtems/score/objectimpl.h>
    30 #include <rtems/score/resourceimpl.h>
    3130#include <rtems/score/schedulernodeimpl.h>
    3231#include <rtems/score/statesimpl.h>
     
    8079
    8180#if defined(RTEMS_SMP)
    82 #define THREAD_RESOURCE_NODE_TO_THREAD( node ) \
    83   RTEMS_CONTAINER_OF( node, Thread_Control, Resource_node )
    84 
    8581#define THREAD_OF_SCHEDULER_HELP_NODE( node ) \
    8682  RTEMS_CONTAINER_OF( node, Thread_Control, Scheduler.Help_node )
     
    975971 *
    976972 * Resources are accounted with the Thread_Control::resource_count resource
    977  * counter.  This counter is used by semaphore objects for example.
    978  *
    979  * In addition to the resource counter there is a resource dependency tree
    980  * available on SMP configurations.  In case this tree is non-empty, then the
    981  * thread owns resources.
     973 * counter.  This counter is used by mutex objects for example.
    982974 *
    983975 * @param[in] the_thread The thread.
     
    987979)
    988980{
    989   bool owns_resources = the_thread->resource_count != 0;
    990 
    991 #if defined(RTEMS_SMP)
    992   owns_resources = owns_resources
    993     || _Resource_Node_owns_resources( &the_thread->Resource_node );
    994 #endif
    995 
    996   return owns_resources;
     981  return the_thread->resource_count != 0;
    997982}
    998983
  • cpukit/score/src/threadinitialize.c

    r73a193f r97f7dac  
    2020
    2121#include <rtems/score/threadimpl.h>
    22 #include <rtems/score/resourceimpl.h>
    2322#include <rtems/score/schedulerimpl.h>
    2423#include <rtems/score/stackimpl.h>
     
    238237  the_thread->Scheduler.own_node = scheduler_node;
    239238  the_thread->Scheduler.node = scheduler_node;
    240   _Resource_Node_initialize( &the_thread->Resource_node );
    241239  _ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" );
    242240  _ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait Default" );
Note: See TracChangeset for help on using the changeset viewer.