-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion about real time thread priorities #1215
Comments
Hi all, |
Here is some more history.
Now, I recall that in the time of old PC104 the RT mode was required to mitigate packet loss. So, why now ICUB_USE_REALTIME_LINUX is off and we dont see the problems of years ago? I think the reason is in point (5): now the system has much more computation capabilities and However, I think that the improved computation capabilities are not enough to guarantee a safe system. And here is a proposal for a way forward:
Notes
Questions
AppendixHere are details of past activities reported in redmine. Issue about Packet loss in PC104In https://redmine.robotology.eu/issues/87 it is fist mentioned that in Oct 2014 @apaikan introduced a variable to toggle on /off I tested that feature for the sake of solving the problem of packet loss in PC104. For those of you who don't have access to redmine, here are some excerpts from the issue:
Issue about CPU load in PC104Moreover, in April 2015 I did some more work with @apaikan focussed to mitigate the CPU load of the old PC104. See https://redmine.robotology.eu/issues/561.
We tested on old iCubGenova04, upper part of a new iCubGenova02, iCubHeidelberg, and later on we deployed on all other ETH robots. |
I agree we should enable realtime support for the software running on the head pc and raise the priority for the ethManager, also making sure it is always on by default and in future installations of the robot. |
Note: This post was edited after @apaikan comment below. Thank you @marcoaccame for this detailed report, well done. Following especially your
Please let me know what's your opinion about. cc @marcoaccame @drdanz @lornat75 @randaz81 @traversaro @francesco-romano @pattacini @barbalberto |
Hi @diegoferigo, it seems fine by me. |
@diegoferigo Please notice that the Ethernet controller thread in RT Linux has priority level of 50.
|
Hi @apaikan and @diegoferigo, two things in parallel:
About 1: I simply don't know. About 2: see also issue #1233. My opinion is that from highest to lowest priorities:
|
@apaikan Thanks for your intervention, it was really helpful! Since you're here, did you choose |
I suggest we start by rising priorities only of |
I updated the first post, I hope now the situation is more clear to everyone. @lornat75 During the last few days, the flag |
Note Cleaning up old issues and pull requests I opened over the past years that are now outdated or stale. If this is still relevant, feel free to reopen it or create a new one with updated details. Thanks! |
The current status of real time thread support in
yarp
is still in experimental status and hence undocumented. This could be a useful feature for critic threads that run intoicub-head
, and could potentially mitigate situations like robotology/icub-tech-support#449.Before starting, some bit of history, at least what I found so far.
Some year ago
yarp
gained the experimental support of tweaking the priorities of important threads (C++11 support, later tweak). BeyondPortCore
, this feature is used in yarprobotinterface and ethManager through theICUB_USE_REALTIME_LINUX
experimental CMake option (default toOFF
). These latter support is unix specific, and this could be the reason of the default value of the mentioned option. More generally, all the classes that inherit fromThreadImpl
have now a multiplatformsetPriority()
method.I have some comments about:
static int setPriority()
method inThreadImpl
that can be called also inethManager
in order to provide multiplatform support and to avoid breaking builds on non-unix machines whenICUB_USE_REALTIME_LINUX=1
ethManager
) should be enabled by default if unix is detectedFor future reference (and to clear my mind), I recap below what I understood about the policy of unix priorities.
There are two kind of tasks, each linked to a different priority range:
SCHED_FIFO
SCHED_RR
SCHED_OTHER
SCHED_NORMAL
RTPRIO=[1, 99]
NICENESS=[-20;19]
RTPRIO
means high priorityNICENESS
means low priorityOne important detail that is worth noting is that internally the kernel handles the queue with a certain logic, and the userspace tools such as
top
show a different range. Yes, it is confusing, and you can find funny discussion in the linux-rt ml. This document and<include/linux/sched/prio.h>
have been really helpful.Here below I'll focus of the
PRI
field you can obtain fromps -eo pid,rtprio,ni,pri,comm
(checkNote#1
at the end of the post). To my understanding, the general priorityPRI=[0:139]
of a thread can be defined as follows:considering:
The range generated by this equation is the following:
Note:
PRI=40
is not allowed. SeeNote#1
below.Notes
Note#1
Something is still not clear, and I hope someone sooner or later could shine light on this.
man ps
reports at its bottom an explanation of the fields that the UNIX-style option-o
can produce. In particular:But, checking at
ps -eo pid,rtprio,ni,pri,comm
, that column is orderered[0, 139]
with low values = low priority logic. You can check yourself grepping the irqs, pulseaudio, etc, that have a biggerPRI
. Apparently I'm not the only one with doubts.References:
Overview of CPU scheduling
A complete guide to Linux process scheduling
Real-Time Linux Kernel Scheduler
RT Preempt HowTO
IRQs in RT kernels
The text was updated successfully, but these errors were encountered: