Timeslice issues with preemption enabled

Kuan-Hsun Chen c0066c at gmail.com
Thu Jun 10 10:09:40 UTC 2021


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.,

   latest version)

There is no definition or clarification about the problem you mentioned. To
answer some of your questions:

   1. I think there is no WHY, but this probably can be patched if we deem
   it as a problem.
   2. 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.

Could you provide your testing code so that we can repeat the same
scenario? I would like to give a try as well.

Best regards,

On Thu, Jun 10, 2021 at 11:25 AM <wangqiang3 at sugon.com> wrote:

> Description of the issue:
> 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.
> 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.
> Hope result:
> 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.
> Actual result:
> 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.
> 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.
> This will cause task C never be scheduled.
> My doubts :
> 1. Why must reset the time slice every time when switch tasks.
> 2. Why the scheduler only pick up Task B as heir task?
> 3. Can I comment the following code in _Thread_Do_dispatch()? Is there
> any problem if I change it this way?
>     if ( heir->budget_algorithm ==
>         heir->cpu_time_budget =
> rtems_configuration_get_ticks_per_timeslice();
> 4. I found that only in POSIX can I use the algorithm
> classics api.nd rtems_task_mode.
> 5. Can anyone give some suggestions to solve the problem? thanks!
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
> --
> Diese Mail wurde mobil geschrieben. Etwaige Rechtschreibfehler sind volle
> Absicht und als großzügiges Geschenk zu verstehen.
> <http://lists.rtems.org/mailman/listinfo/users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20210610/455a78f1/attachment.html>

More information about the users mailing list