Timeslice issues with preemption enabled

Joel Sherrill joel at rtems.org
Thu Jun 10 15:47:47 UTC 2021

On Thu, Jun 10, 2021 at 9:58 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> On 10/06/2021 16:24, Gedare Bloom wrote:
> >>> 5. Can anyone give some suggestions to solve the problem? thanks!
> > Classic and POSIX APIs can be mixed. It is a poorly documented benefit
> > of RTEMS. I think in this case, you should be able to use
> > pthread_setschedparam(...) with passing policy == SCHED_RR to get the
> > behavior you seek. You have to use posix priorities in the sched_param
> > argument. though, or else your thread will have its priority changed.
> > Pass the task_id instead of pthread_t as the first argument, and the
> > rest should work itself out. Do let us know if that works or it
> > doesn't work/you have more questions.
> You can use these directives to convert priority values:
> https://docs.rtems.org/branches/master/c-user/scheduling-concepts/directives.html#rtems-scheduler-map-priority-to-posix
> In general, the timeslicing based on clock tick quantum is quite coarse.
> The internal timestamps would allow a much finer grained timeslicing.
> This could be added if someone is interested in a small project.

TImeslicing accounting requires something to invoke the update method.
The only "trigger" is the clock tick. Turning the tick quantum down doesn't
add a lot of overhead. One millisecond is certainly not an issue on even
low end hardware. And then have a timeslice of 1 tick.

Also the timeslice value is the same across all threads.

If you are depending on timeslicing in your application to share the CPU
across threads, then you probably should at least consider why they are
using that much uninterrupted CPU time and ensure you have accounted
for that in your design.


> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.huber at embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20210610/86612963/attachment.html>

More information about the users mailing list