<div dir="ltr">Great explanation. This makes sense. Thank you, I will look further into this.<br><div><br></div><div>Thanks </div><div>Richi.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 10, 2021 at 8:48 PM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</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"><div dir="ltr"><div dir="ltr">Hi Richi,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 4, 2021 at 10:53 AM Richi Dubey <<a href="mailto:richidubey@gmail.com" target="_blank">richidubey@gmail.com</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"><div dir="ltr">Hi,<div><br></div><div>I am debugging a code (<a href="https://git.rtems.org/rtems/tree/testsuites/tmtests/tm24/task1.c" target="_blank">tm24</a>) and there is a scenario where a thread is blocked on the CPU and a new thread has to start executing in its place. So, the thread which is getting blocked (executing thread) executes the _Thread_Do_dispatch and runs the code <a href="https://git.rtems.org/rtems/tree/cpukit/score/src/threaddispatch.c#n308" target="_blank">until </a>:</div>_Context_Switch( &executing->Registers, &heir->Registers ). After this, the heir thread starts executing from _Thread_Handler. Why is this the case? Should the heir not start its execution from where the (earlier) executing thread left the program counter at, i.e. after the _Context_Switch in _Thread_Do_dispatch?<div><br></div></div></blockquote><div><br></div><div>I think Sebastian answered this for you before? The heir thread will resume execution wherever its PC value is pointing to, which does not need to be the same place that the executing task is departing. In RTEMS however the cases are fairly limited, with the PC of a task that never executed before pointing into _Thread_Handler, because you have to start somewhere. For tasks that have been executing before and have been preempted/yielded, they will go through the _Thread_Do_dispatch code and their stored PC will indeed resume them at that point you mention.</div><div><br></div><div>Gedare</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>Please let me know your thoughts.</div><div><br></div><div>Thanks,</div><div>Richi.<br><div>  </div></div></div>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a></blockquote></div></div>
</blockquote></div>