<div dir="ltr">Thanks for the quick response, I checked out the functions and I have some idea now.<div>Is it okay I directly call _Thread_Dispatch_enable while calling SMP_Preempt (since the latter does not call it) on another processor? This question is wrt the code at this <a href="https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L245">line</a>. </div><div><br></div><div>This question has comes up because set_affinity does the following in the order:</div><div>_Scheduler_SMP_Preempt_and_schedule_highest_ready<br></div><div>set_affinity<br></div><div>enqueue.<br></div><div><br></div><div>The strong APA's highest_ready preempt a different cpu and allocates a thread. This CPU can again be preempted while calling the enqueue corresponding to Strong APA, at which point it would require the latest scheduled thread on it (the one just assigned it to by highest_ready if it's the case).</div><div><br></div><div>Please let me know. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 21, 2020 at 2:20 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 21/08/2020 10:40, Richi Dubey wrote:<br>
<br>
> While trying to debug my code, I realised that the heir set on another <br>
> processor does not become that cpu's per_cpu_control->executing after <br>
> some time.<br>
><br>
> On checking the allocate_processor call that set the heir, I saw the <br>
> call trace as:<br>
><br>
> _Scheduler_SMP_Allocate_processor_exact -> _Thread_Dispatch_update_heir :<br>
><br>
> -------------------------------------<br>
> ...<br>
> } else { (Here this gets executed since the current cpu is different <br>
> than the one that gets its executing changed)<br>
> _Atomic_Fetch_or_ulong( &cpu_target->message, 0, <br>
> ATOMIC_ORDER_RELEASE );<br>
> _CPU_SMP_Send_interrupt( _Per_CPU_Get_index( cpu_target ) );<br>
> }<br>
><br>
> ............................................<br>
><br>
> So, how long does it take for heir to become executing on another cpu? <br>
> This question is wrt my code at this line <br>
> <<a href="https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L297" rel="noreferrer" target="_blank">https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L297</a>>. <br>
> Is it okay if i use heir here instead of executing (To get the latest <br>
> thread intended to be scheduled on the cpu)? Would it mean the same <br>
> thing? Is heir==executing when thread_dispatch is set to false?<br>
The thread dispatching uses the per-processor variables executing, heir, <br>
and is_dispatch_necessary. Thread dispatching is always a per-processor <br>
operation. If you want to carry out a thread dispatch on another <br>
processor you have to use an inter-processor interrupt. For the control <br>
flow, see _Thread_Do_dispatch(). Check the variables on the other <br>
processor. After updating the variables you can set a break point to the <br>
inter-processor interrupt handler and check if it is called.<br>
</blockquote></div>