<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Here we remove the affine ready queue if it<br> exists from the chain of affine queues since now an affine thread is<br>  scheduled on a processor.</blockquote><div>Why are we removing the entire affine queue corresponding to a CPU when a single node of the queue gets scheduled?  </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 14, 2020 at 2:51 PM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 14/07/2020 11:11, Sebastian Huber wrote:<br>
<br>
> On 14/07/2020 10:47, Richi Dubey wrote:<br>
><br>
>> Can someone please help me understand how this <br>
>> (<a href="https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385" rel="noreferrer" target="_blank">https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385</a>) <br>
>> if condition works. Why are we removing the ready queue Node from the <br>
>> chain of Affine queues when we are allocating a different processor <br>
>> (<a href="https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398" rel="noreferrer" target="_blank">https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398</a>) <br>
>> to the node which was currently scheduled on the CPU of that (the <br>
>> ready queue mentioned in the if condition's) ready queue?<br>
><br>
> |static inline void _Scheduler_EDF_SMP_Allocate_processor( <br>
> Scheduler_Context *context, Scheduler_Node *scheduled_base, <br>
> Scheduler_Node *victim_base, Per_CPU_Control *victim_cpu ) { <br>
> Scheduler_EDF_SMP_Context *self; Scheduler_EDF_SMP_Node *scheduled; <br>
> uint8_t rqi; (void) victim_base; self = _Scheduler_EDF_SMP_Get_self( <br>
> context ); scheduled = _Scheduler_EDF_SMP_Node_downcast( <br>
> scheduled_base ); rqi = scheduled->ready_queue_index; if ( rqi != 0 ) <br>
> { Scheduler_EDF_SMP_Ready_queue *ready_queue; Per_CPU_Control <br>
> *desired_cpu; ready_queue = &self->Ready[ rqi ]; if ( <br>
> !_Chain_Is_node_off_chain( &ready_queue->Node ) ) { <br>
> _Chain_Extract_unprotected( &ready_queue->Node ); <br>
> _Chain_Set_off_chain( &ready_queue->Node ); } Here we remove the <br>
> affine ready queue if it exists from the chain of affine queues since <br>
> now an affine thread is scheduled on a processor.  desired_cpu = <br>
> _Per_CPU_Get_by_index( rqi - 1 ); if ( victim_cpu != desired_cpu ) { <br>
> Scheduler_EDF_SMP_Node *node; This is another action. If the victim <br>
> CPU is not the right one for the new scheduled node, we have to make <br>
> room for it on the desired CPU.  node = <br>
> _Scheduler_EDF_SMP_Get_scheduled( self, rqi ); _Assert( <br>
> node->ready_queue_index == 0 ); _Scheduler_EDF_SMP_Set_scheduled( <br>
> self, node, victim_cpu ); _Scheduler_SMP_Allocate_processor_exact( <br>
> context, &node->Base.Base, NULL, victim_cpu ); victim_cpu = <br>
> desired_cpu; } }|<br>
<br>
Sorry for the format.<br>
<br>
static inline void _Scheduler_EDF_SMP_Allocate_processor(<br>
   Scheduler_Context *context,<br>
   Scheduler_Node    *scheduled_base,<br>
   Scheduler_Node    *victim_base,<br>
   Per_CPU_Control   *victim_cpu<br>
)<br>
{<br>
   Scheduler_EDF_SMP_Context     *self;<br>
   Scheduler_EDF_SMP_Node        *scheduled;<br>
   uint8_t                        rqi;<br>
<br>
   (void) victim_base;<br>
   self = _Scheduler_EDF_SMP_Get_self( context );<br>
   scheduled = _Scheduler_EDF_SMP_Node_downcast( scheduled_base );<br>
   rqi = scheduled->ready_queue_index;<br>
<br>
   if ( rqi != 0 ) {<br>
     Scheduler_EDF_SMP_Ready_queue *ready_queue;<br>
     Per_CPU_Control               *desired_cpu;<br>
<br>
     ready_queue = &self->Ready[ rqi ];<br>
<br>
     if ( !_Chain_Is_node_off_chain( &ready_queue->Node ) ) {<br>
       _Chain_Extract_unprotected( &ready_queue->Node );<br>
       _Chain_Set_off_chain( &ready_queue->Node );<br>
     }<br>
<br>
Here we remove the affine ready queue if it exists from the chain of <br>
affine queues since now an affine thread is scheduled on a processor.<br>
<br>
     desired_cpu = _Per_CPU_Get_by_index( rqi - 1 );<br>
<br>
     if ( victim_cpu != desired_cpu ) {<br>
       Scheduler_EDF_SMP_Node *node;<br>
<br>
This is another action. If the victim CPU is not the right one for the <br>
new scheduled node, we have to make room for it on the desired CPU.<br>
<br>
       node = _Scheduler_EDF_SMP_Get_scheduled( self, rqi );<br>
       _Assert( node->ready_queue_index == 0 );<br>
       _Scheduler_EDF_SMP_Set_scheduled( self, node, victim_cpu );<br>
       _Scheduler_SMP_Allocate_processor_exact(<br>
         context,<br>
         &node->Base.Base,<br>
         NULL,<br>
         victim_cpu<br>
       );<br>
       victim_cpu = desired_cpu;<br>
     }<br>
   }<br>
<br>
</blockquote></div>