[PATCH 13/27] score: Optimize SMP EDF move to ready operation

Gedare Bloom gedare at rtems.org
Sat Nov 20 20:09:16 UTC 2021


On Mon, Nov 15, 2021 at 10:13 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> If a node is moved from the scheduled chain to the ready queue, then we
> know that it is the highest priority ready node.  So, it can be
> prepended to the ready queue without doing any comparisons.
>
I'm not certain on the logic here. It is possible for 2 threads X and
Y become ready simultaneously, such that:

X is higher priority than Y. X and Y are higher priority than Z. X
gets scheduled to replace Z, but there is no lower-priority/affine CPU
for Y to get scheduled, so Y will be ready. Then Z is not
higher-priority than Y so it shouldn't be directly prepended.

I think that could happen?

> Update #4531.
> ---
>  cpukit/score/src/scheduleredfsmp.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/cpukit/score/src/scheduleredfsmp.c b/cpukit/score/src/scheduleredfsmp.c
> index 7da777e87a..27be08ac40 100644
> --- a/cpukit/score/src/scheduleredfsmp.c
> +++ b/cpukit/score/src/scheduleredfsmp.c
> @@ -374,15 +374,21 @@ static inline void _Scheduler_EDF_SMP_Move_from_scheduled_to_ready(
>    Scheduler_Node    *scheduled_to_ready
>  )
>  {
> -  Priority_Control insert_priority;
> +  Scheduler_EDF_SMP_Context     *self;
> +  Scheduler_EDF_SMP_Node        *node;
> +  uint8_t                        rqi;
> +  Scheduler_EDF_SMP_Ready_queue *ready_queue;
>
>    _Scheduler_EDF_SMP_Extract_from_scheduled( context, scheduled_to_ready );
> -  insert_priority = _Scheduler_SMP_Node_priority( scheduled_to_ready );
> -  _Scheduler_EDF_SMP_Insert_ready(
> -    context,
> -    scheduled_to_ready,
> -    insert_priority
> -  );
> +
> +  self = _Scheduler_EDF_SMP_Get_self( context );
> +  node = _Scheduler_EDF_SMP_Node_downcast( scheduled_to_ready );
> +  rqi = node->ready_queue_index;
> +  ready_queue = &self->Ready[ rqi ];
> +
> +  _Scheduler_EDF_SMP_Activate_ready_queue_if_necessary( self, rqi, ready_queue );
> +  _RBTree_Initialize_node( &node->Base.Base.Node.RBTree );
> +  _RBTree_Prepend( &ready_queue->Queue, &node->Base.Base.Node.RBTree );
>  }
>
>  static inline void _Scheduler_EDF_SMP_Move_from_ready_to_scheduled(
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list