<div dir="ltr">Hi,<br><div><br></div><div>Could you please explain what _User_extensions_Thread_start does? It's hard to understand it all by myself since it has a lot of other information related to objects.</div><div><br></div><div>The brief for it says: </div><div>/**<br> * @brief Starts a thread.<br> *<br> * @param created The thread to start.<br> */<br></div><div><br></div><div>This is exactly what my doubt was. When we unlocked the node by setting the state to ready by calling _Thread_Clear_state_locked, shouldn't the node be scheduled if the scheduler sees it fit? Why are we enabling thread dispatch on the current cpu (Shouldn't it depend on the affinity of the thread)?</div><div><br></div><div>Please tell me what happens in principle after calling _Thread_Clear_state_locked().</div><div><br></div><div>Thank you.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 11:42 AM Richi Dubey <<a href="mailto:richidubey@gmail.com">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><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">_Thread_Clear_state_locked( the_thread, STATES_ALL_SET );</blockquote><div>I did have a look at it, it unblocks the node belonging to the_thread, I'll go through everything again.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When you use the debugger to figure out what is going on I would step in<br>to each function you don't know.</blockquote><div>Got it. Thank you. </div><div> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 20, 2020 at 9:24 PM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">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 20/07/2020 17:16, Richi Dubey wrote:<br>
<br>
> Hi,<br>
><br>
> I am trying to map out how a task gets scheduled according to a <br>
> scheduling algorithm once a user writes rtems_task_create() and later <br>
> rtems_task_start() in the source file.<br>
><br>
> On debugging with gdb, I came to realize that the<br>
><br>
> rtems_task_start() function calls _Thread_Start() <br>
> (cpukit/rtems/src/taskstart.c : 56) then _Thread_Start() calls  <br>
> _Thread_Dispatch_enable() ( cpukit/score/src/threadstart.c : 50 ) then<br>
> _Thread_Dispatch_enable() calls _Thread_Do_dispatch( ) <br>
> (cpukit/score/src/threaddispatch.c : 377)<br>
> and _Thread_Do_dispatch calls _Thread_Get_heir_and_make_it_executing() <br>
> (threaddispatch.c : 282).<br>
><br>
> _Thread_Get_heir_and_make_it_executing( cpu_self ) forcefully executes <br>
> the heir thread on the cpu_self. <br>
> (cpukit/include/rtems/score/threadimpl.h : 1117)<br>
><br>
> If I am right, this flow of code makes the thread created by <br>
> rtems_task_create(..., id) execute on a CPU when rtems_task_start(..., <br>
> id) is called.  Shouldn't this decision of executing a thread on any <br>
> CPU be in the hands of the scheduler?  I'd be grateful if someone <br>
> could provide their views on this.<br>
<br>
Yes, the scheduler decides which of the ready threads gets a scheduler <br>
assigned. In _Thread_Start() please have a look at:<br>
<br>
_Thread_Clear_state_locked( the_thread, STATES_ALL_SET );<br>
<br>
><br>
> Also, what is thread_dispatch_disable_level?<br>
<br>
This is a per-CPU variable. If thread_dispatch_disable_level != 0, then <br>
thread changes are prohibited on this processor. If it changes from 1 to <br>
0, then it is checked if a thread dispatch is necessary.<br>
<br>
> Please know that I skipped reading some if conditions and some code <br>
> related to ISRs and other things that weren't directly related to <br>
> scheduling.<br>
When you use the debugger to figure out what is going on I would step in <br>
to each function you don't know.<br>
</blockquote></div>
</blockquote></div>