[PATCH] Add SMP Priority Scheduler with Affinity

Gedare Bloom gedare at rtems.org
Tue Jun 10 12:54:41 UTC 2014


> diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
> index 317d8ce..b2c5825 100644
> --- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
> +++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
[...]
> +/*
> + * This method is unique to this scheduler because it takes into
> + * account affinity as it determines the highest ready thread.
> + * Since this is used to pick a new thread to replace the victim,
> + * the highest ready thread must have affinity such that it can
> + * be executed on the victim's processor.
> + */
> +static Thread_Control *_Scheduler_priority_affinity_SMP_Get_highest_ready(
> +  Scheduler_Context *context,
> +  Thread_Control    *victim
> +)
> +{
> +  Scheduler_priority_SMP_Context *self =
> +    _Scheduler_priority_SMP_Get_self( context );
> +  Priority_Control                index;
> +  Thread_Control                 *highest = NULL;
> +  int                             victim_cpu;
> +
> +  /*
> +   * This is done when we need to check if reevaluations are needed.
> +   */
> +  if ( victim == NULL ) {
> +    return _Scheduler_priority_Ready_queue_first(
> +        &self->Bit_map,
> +        &self->Ready[ 0 ]
> +      );
> +  }
> +
> +  victim_cpu = _Per_CPU_Get_index( _Thread_Get_CPU( victim ) );
> +
> +  /*
> +   * The deterministic priority scheduler structure is optimized
> +   * for insertion, extraction, and finding the highest priority
> +   * thread. Scanning the list of ready threads is not a purpose
> +   * for which it was optimized. There are optimizations to be
> +   * made in this loop.
This note deserves to be called out a little more with e.g. a TODO tag.

> +   *
> +   * + by checking the major bit, we could potentially skip entire
> +   *   groups of 16.
> +   */
> +  for ( index = _Priority_bit_map_Get_highest( &self->Bit_map ) ;
> +        index <= PRIORITY_MAXIMUM;
> +        index++ ) {
The closing parens and opening brace should be on its own line.

> +    Chain_Control   *chain =  &self->Ready[index];
> +    Chain_Node      *chain_node;
> +    for ( chain_node = _Chain_First( chain );
> +          chain_node != _Chain_Immutable_tail( chain ) ;
> +          chain_node = _Chain_Next( chain_node ) ) {
same

[...]
> diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
> index 7915ce6..bf62e69 100644
> --- a/cpukit/score/src/schedulerprioritysmp.c
> +++ b/cpukit/score/src/schedulerprioritysmp.c
> @@ -26,6 +26,7 @@
>
>  #include <rtems/score/schedulerprioritysmp.h>
>  #include <rtems/score/schedulerpriorityimpl.h>
> +#include <rtems/score/schedulerprioritysmpimpl.h>
>  #include <rtems/score/schedulersmpimpl.h>
>
>  static Scheduler_priority_SMP_Context *
> @@ -34,13 +35,14 @@ _Scheduler_priority_SMP_Get_context( const Scheduler_Control *scheduler )
>    return (Scheduler_priority_SMP_Context *) _Scheduler_Get_context( scheduler );
>  }
>
> -static Scheduler_priority_SMP_Context *
> -_Scheduler_priority_SMP_Get_self( Scheduler_Context *context )
> +Scheduler_priority_SMP_Context *_Scheduler_priority_SMP_Get_self(
> +  Scheduler_Context *context
> +)
>  {
>    return (Scheduler_priority_SMP_Context *) context;
>  }
>
> -static Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Node_get(
> +Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Node_get(
>    Thread_Control *thread
>  )
>  {
> @@ -74,7 +76,7 @@ void _Scheduler_priority_SMP_Node_initialize(
>    _Scheduler_SMP_Node_initialize( node );
>  }
>
> -static void _Scheduler_priority_SMP_Do_update(
> +void _Scheduler_priority_SMP_Do_update(
>    Scheduler_Context *context,
>    Scheduler_Node *base_node,
>    Priority_Control new_priority
> @@ -106,19 +108,22 @@ void _Scheduler_priority_SMP_Update_priority(
>  }
>
>  static Thread_Control *_Scheduler_priority_SMP_Get_highest_ready(
> -  Scheduler_Context *context
> +  Scheduler_Context *context,
> +  Thread_Control    *thread
>  )
>  {
>    Scheduler_priority_SMP_Context *self =
>      _Scheduler_priority_SMP_Get_self( context );
>
> +  (thread);
> +
This should be (void) thread;

[...]
> diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c
> index 029da67..1fd2931 100644
> --- a/cpukit/score/src/schedulersimplesmp.c
> +++ b/cpukit/score/src/schedulersimplesmp.c
> @@ -64,12 +64,15 @@ static void _Scheduler_simple_SMP_Do_update(
>  }
>
>  static Thread_Control *_Scheduler_simple_SMP_Get_highest_ready(
> -  Scheduler_Context *context
> +  Scheduler_Context *context,
> +  Thread_Control    *thread
>  )
>  {
>    Scheduler_simple_SMP_Context *self =
>      _Scheduler_simple_SMP_Get_self( context );
>
> +  (thread);
> +
same.

-Gedare



More information about the devel mailing list