<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">No, this would be completely wrong. You should never call<br>_Thread_Dispatch_enable(other_cpu) and you should never modify the<br>thread dispatch level inside the scheduler code. The only thing you can<br>do is to update the heir and send requests via an inter-processor interrupt.</blockquote><div>Okay. So, to deal with the unpredictable time is it okay if I use heir instead of executing in the following place (my aim is to get the latest executing thread / to be executed thread on a cpu):</div><div><br></div><div><br></div><div><a href="https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L243">https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L243</a><br></div><div><a href="https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L467">https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L467</a><br></div><div><a href="https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L248">https://github.com/richidubey/rtems/blob/03d08d02b3e61570f2022845caa44ec6a261f677/cpukit/score/src/schedulerstrongapa.c#L248</a><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 21, 2020 at 3:12 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 11:34, Richi Dubey wrote:<br>
<br>
> _SMP_Preempt calls _Thread_Dispatch_update_heir which <br>
> calls _Thread_Dispatch_request which sends an interrupt <br>
> with _CPU_SMP_Send_interrupt.<br>
Yes.<br>
> This interrupt would have set the executing equal to heir but would've <br>
> taken unpredictable time,<br>
Yes, this is how it works. The scheduler asks for a thread dispatch, but <br>
when it takes place is out of the control of the scheduler.<br>
> but explicitly calling _Thread_Dispatch_enable(other_cpu) right after <br>
> _SMP_Preempt(...node_on_other_cpu...) sets the executing corresponding <br>
> to the other_cpu's cpu control right away, is that correct?<br>
No, this would be completely wrong. You should never call <br>
_Thread_Dispatch_enable(other_cpu) and you should never modify the <br>
thread dispatch level inside the scheduler code. The only thing you can <br>
do is to update the heir and send requests via an inter-processor interrupt.<br>
</blockquote></div>