<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Hello,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"></div><div class="gmail_default" style="font-family:verdana,sans-serif">If that is the case, I think we should probably first agree on, what is the preferred behavior under the circumstance. I think picking heir tasks always in the same order is a proper design, but the preemption should not corrupt the "fair" time slicing in my opinion (so follow what you observe). From what I can find in the documents or source code, e.g.,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><ul><li><a href="https://docs.rtems.org/branches/master/c-user/task/background.html?highlight=slice#task-priority" target="_blank">https://docs.rtems.org/branches/master/c-user/task/background.html?highlight=slice#task-priority</a> (the latest version)</li><li><a href="https://docs.rtems.org/releases/rtemsdocs-4.6.2/share/rtems/html/c_user/c_user00303.html" target="_blank">https://docs.rtems.org/releases/rtemsdocs-4.6.2/share/rtems/html/c_user/c_user00303.html</a> (old version)</li><li><a href="https://github.com/RTEMS/rtems/blob/master/cpukit/include/rtems/rtems/tasks.h" target="_blank">https://github.com/RTEMS/rtems/blob/master/cpukit/include/rtems/rtems/tasks.h</a> <br></li></ul><div>There is no definition or clarification about the problem you mentioned. To answer some of your questions:</div><div><ol><li>I think there is no WHY, but this probably can be patched if we deem it as a problem. </li><li>Timeslicing in RTOS usually follows a round-robin manner according to an given order. To have a determinate behavior, I think it makes sense that it always pick Task B as heir task.</li></ol><div>Could you provide your testing code so that we can repeat the same scenario? I would like to give a try as well.<br></div><div><br></div><div>Best regards,<br>Kuan-Hsun</div></div></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 10, 2021 at 11:25 AM <<a href="mailto:wangqiang3@sugon.com" target="_blank">wangqiang3@sugon.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"><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><div><span style="font-family:Verdana,Arial,Helvetica,sans-serif">Description of the issue:</span></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">I created three tasks, Task A, Task B and Task C. All tasks are based on RTEMS_TIMESLICE | RTEMS_PREEMPT , Task A has a higher priority than other tasks, Task B has the same priority as Task C.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">Tasks B and C loop forever, Task A sleeps 1 TICK on an endless loop. When I test, I find that task C is not scheduled.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">Hope result:</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">I was expecting tasks A, B, and C to be scheduled. Task A can preempt task B and C. Tasks B and C can switch to each other when the time slice runs out.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">Actual result:</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">When task A preempts task B and run out its timeslice, then switch to task B, task B's timeslice will reset to _Watchdog_Ticks_per_timeslice.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">While the task B is still running, Task A preempts task B again. Task A will pick up task B as heir task and reset task B's timeslice.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">This will cause task C never be scheduled.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">My doubts :</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">1. Why must reset the time slice every time when switch tasks.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">2. Why the scheduler only pick up Task B as heir task?</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">3. Can I comment the following code in _Thread_Do_dispatch()</span></font><span style="font-family:Verdana,Arial,Helvetica,sans-serif">? Is there any problem if I change it this way?</span></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px"> if ( heir->budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE )</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px"> heir->cpu_time_budget = rtems_configuration_get_ticks_per_timeslice();</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">4. I found that only in POSIX can I use the algorithm THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE , RTEMS classics api only can use THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px"> Can I use THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE in RTEMS classics api.nd rtems_task_mode.</span></font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:12.8px">5. Can anyone give some suggestions to solve the problem? thanks!</span></font></div><div></div></font>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users<br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Diese Mail wurde mobil geschrieben. Etwaige Rechtschreibfehler sind volle Absicht und als großzügiges Geschenk zu verstehen.<br></div></div> <br></a></blockquote></div></div>