<div dir="ltr">Hi,<div><br></div><div>Can someone please help me with this?</div><div><br></div><div>The strong apa scheduler code that I am trying to debug never goes _Thread_Handler function, while the default priority scheduler's code does go to _Thread_Handler function:</div><div><br></div><div>Strong APA trace:</div><div>-----------------------------------------------------------<br></div><div>(gdb) b _Thread_Handler<br>(gdb) b _Thread_Do_dispatch <br>(gdb) c<br>Continuing.<br><br>Thread 1 hit Breakpoint 11, _Thread_Do_dispatch (cpu_self=0x200540 <_Per_CPU_Information>, level=1611596115) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threaddispatch.c:267<br>267 !_ISR_Is_enabled( level )<br>(gdb) ni<br>...<br>305 _Context_Switch( &executing->Registers, &heir->Registers );<br>(gdb) si<br>...<br>121 ldm r1, {r4, r5, r6, r7, r8, r9, r10, r11, r13, pc}<br>(gdb) <br>_Thread_Do_dispatch (cpu_self=0x200540 <_Per_CPU_Information>, level=1611596115) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threaddispatch.c:306<br>306 _Thread_Restore_fp( executing );<br>(gdb) <br>0x001081aa 306 _Thread_Restore_fp( executing );<br>(gdb) ni<br>...<br>0x001081e6 328 _Thread_Run_post_switch_actions( executing );<br>(gdb) <br>329 }<br>(gdb) <br>_Thread_Dispatch_direct (cpu_self=0x200540 <_Per_CPU_Information>) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threaddispatch.c:360<br>360 }<br>(gdb) <br>rtems_task_wake_after (ticks=0) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/rtems/src/taskwakeafter.c:47<br>47 return RTEMS_SUCCESSFUL;<br>(gdb) <br>48 }<br>Tasks (argument=0) at /home/richi/quick-start/src/rtems/c/src/../../testsuites/tmtests/tm24/task1.c:129<br>_Thread_Entry_adaptor_numeric (executing=0x201980 <_RTEMS_tasks_Objects+2576>) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threadentryadaptornumeric.c:26<br>26 }<br>(gdb) <br>_Thread_Handler () at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threadhandler.c:152<br>152 _User_extensions_Thread_exitted( executing );<br>(gdb) <br>0x00108708 152 _User_extensions_Thread_exitted( executing );<br>(gdb) <br>154 _Internal_error( INTERNAL_ERROR_THREAD_EXITTED );<br>(gdb) <br>0x0010870e 154 _Internal_error( INTERNAL_ERROR_THREAD_EXITTED );<br>(gdb) <br><br>Thread 1 hit Breakpoint 5, _Terminate (the_source=INTERNAL_ERROR_CORE, the_error=5) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/interr.c:36<br>36 _User_extensions_Fatal( the_source, the_error );<br>(gdb) <br>0x0010e37e 36 _User_extensions_Fatal( the_source, the_error );<br>(gdb) <br></div><div><br></div><div>-----------------------------------------------------------</div><div><br></div><div>Priority Scheduler's trace:</div><div><br></div><div>---------------------------------------------------</div><div>(gdb) b _Thread_Handler<br>(gdb) b _Thread_Do_dispatch <br><br>(gdb) c<br>Continuing.<br><br>Thread 1 hit Breakpoint 15, _Thread_Do_dispatch (cpu_self=0x200540 <_Per_CPU_Information>, level=1611596115) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threaddispatch.c:267<br>267 !_ISR_Is_enabled( level )<br>(gdb) ni<br>...<br>0x0010a170 305 _Context_Switch( &executing->Registers, &heir->Registers );<br>(gdb) <br>_CPU_Context_switch () at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/cpu/arm/cpu_asm.S:56<br>56 DEFINE_FUNCTION_ARM(_CPU_Context_switch)<br>(gdb) <br>...<br>121 ldm r1, {r4, r5, r6, r7, r8, r9, r10, r11, r13, pc}<br>(gdb) <br>_Thread_Handler () at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threadhandler.c:77<br>77 {<br>(gdb) <br>0x0010a67a 77 {<br>(gdb) ni<br>0x0010a67c 77 {<br>(gdb) <br><br>Thread 1 hit Breakpoint 14, _Thread_Handler () at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threadhandler.c:88<br>88 executing = _Thread_Executing;<br>(gdb) <br>0x0010a682 88 executing = _Thread_Executing;<br>(gdb) <br>0x0010a684 88 executing = _Thread_Executing;<br>(gdb) ni<br>...<br>(gdb) si<br>0x0010a6b8 126 _Thread_Do_dispatch( cpu_self, level );<br>(gdb) <br>_Thread_Do_dispatch (cpu_self=0x22ba40, level=2275904) at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threaddispatch.c:260<br>260 {<br>(gdb) <br>...<br>0x0010a1b2 328 _Thread_Run_post_switch_actions( executing );<br>(gdb) <br>329 }<br>(gdb) <br>_Thread_Handler () at /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/threadhandler.c:134<br>134 _User_extensions_Thread_begin( executing );<br>(gdb) <br>0x0010a6be 134 _User_extensions_Thread_begin( executing );<br>(gdb) <br>136 _Thread_Global_construction( executing );<br>(gdb) <br>0x0010a6c4 136 _Thread_Global_construction( executing );<br>(gdb) <br>143 ( *executing->Start.Entry.adaptor )( executing );<br>(gdb) <br>0x0010a6ca 143 ( *executing->Start.Entry.adaptor )( executing );<br>(gdb) <br>0x0010a6ce 143 ( *executing->Start.Entry.adaptor )( executing );<br>(gdb) <br>0x0010a6d0 143 ( *executing->Start.Entry.adaptor )( executing );<br>(gdb) </div><div><br>Thread 1 hit Breakpoint 13, Tasks (argument=0) at /home/richi/quick-start/src/rtems/c/src/../../testsuites/tmtests/tm24/task1.c:110<br>110 Task_count++;<br>(gdb) <br>0x00100eda 110 Task_count++;<br>(gdb) <br>0x00100ede 110 Task_count++;</div><div>-------------------</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 4, 2021 at 11:22 PM 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><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>Please let me know your thoughts.</div><div><br></div><div>Thanks,</div><div>Richi.<br><div> </div></div></div>
</blockquote></div>